United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-2126509 : java.net.Socket checks for old-style impls

Details
Type:
Backport
Submit Date:
2005-05-24
Status:
Resolved
Updated Date:
2011-12-21
Project Name:
JDK
Resolved Date:
2005-10-21
Component:
core-libs
OS:
Sub-Component:
java.net
CPU:
Priority:
P4
Resolution:
Fixed
Affected Versions:
Fixed Versions:
1.4.2_11 (b01)

Related Reports
Backport:

Sub Tasks

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.
*** (#1 of 1): 2004-08-27 22:42:02 PDT ###@###.###
*** Last Edit: 2005-08-10 06:57:10 PDT ###@###.###

                                    

Comments
EVALUATION

webrev fix is available here: 
http://javaweb.eng/~tm157638/webrevs/5089488/1.4.2/

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
*** (#1 of 2): 2004-08-27 22:44:56 PDT ###@###.###

I guess we need to call getDeclaredMethod() for each super-class
until we find the connect method.
*** (#2 of 2): 2005-08-10 06:57:10 PDT ###@###.###
                                     
2005-09-22
SUGGESTED FIX

webrev fix is available here: 
http://javaweb.eng/~tm157638/webrevs/5089488/1.4.2/
                                     
2005-09-22
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
*** (#1 of 2): 2004-08-27 22:44:56 PDT ###@###.###

I guess we need to call getDeclaredMethod() for each super-class
until we find the connect method.
*** (#2 of 2): 2005-08-10 06:57:10 PDT ###@###.###
                                     
2005-08-25



Hardware and Software, Engineered to Work Together