JDK-5089488 : java.net.Socket checks for old-style impls
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P4
  • Affected Version: 6
  • OS: solaris_9
  • CPU: generic
  • Submit Date: 2004-08-19
  • Updated Date: 2005-08-19
  • Resolved Date: 2005-08-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other JDK 6
1.4.2_11Resolved 6 betaResolved
Related Reports
Relates :  
Relates :  
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.

Comments
SUGGESTED FIX Webrev for the mustang: http://oldsunweb.ireland/~mm72272/webrev/current/webrev.5089488/ Webrev for Tiger: http://javaweb/~tm157638/webrevs/5089488/1.5.0/ Webrev for Mantis: http://javaweb/~tm157638/webrevs/5089488/1.4.2/
2005-08-22

EVALUATION I guess we need to call getDeclaredMethod() for each super-class until we find the connect method.
2005-08-10

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
2004-08-28

WORK AROUND The workaround is to define the method on both classes.
2004-08-28

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. ###@###.### 2004-08-27
2004-08-27