Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5089488
Votes 1
Synopsis java.net.Socket checks for old-style impls
Category java:classes_net
Reported Against 1.4.2_05
Release Fixed mustang(beta), 1.4.2_11(b01) (Bug ID:2126509) , 5.0u7(b01) (Bug ID:2128660)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4674826 , 6449565
Submit Date 19-AUG-2004
Description
We note that BugID: 4674826 is fixed in 142 release.

However, java.net.Socket checks for old-style impls like this:

    private void checkOldImpl() {
    if (impl == null)
        return;
    // SocketImpl.connect() is a protected method, therefore we need to use
    // getDeclaredMethod, therefore we need permission to access the member
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction() {
            public Object run() throws NoSuchMethodException {
            Class[] cl = new Class[2];
            cl[0] = SocketAddress.class;
            cl[1] = Integer.TYPE;
            impl.getClass().getDeclaredMethod("connect", cl);
            return null;
            }
        });
    } catch (java.security.PrivilegedActionException e) {
        oldImpl = true;
    }
    }

However, my understanding is that this will exclude inherited methods on the impl. In our instance we have a BSocketImpl that inherits from ASocketImpl where only ASocketImpl has the appropriate connect() method. java.net.Socket therefor wrongly assumes that it is an old-style impl.
Posted Date : 2005-08-10 13:57:10.0
Work Around
The workaround is to define the method on both classes.
Evaluation
Indeed, getDeclaredMethod throws a NoSuchMethodException if the protected method was inherited, but getMethod() will throw the same exception no matter what because the method is protected.
We need to find a better test for Mustang.

jean-  xxxxx@xxxxx   2004-08-27
I guess we need to call getDeclaredMethod() for each super-class
until we find the connect method.
Posted Date : 2005-08-10 13:57:10.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang