JDK-6449565 : Pre-1.4 SocketImpl no longer supported
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2006-07-17
  • Updated: 2019-02-28
  • Resolved: 2006-08-05
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 Availability Release.

To download the current JDK release, click here.
Other JDK 6
1.4.2_13Fixed 6 b95Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux localhost.localdomain 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
By trivial inspection Socket.checkOldImpl always sets oldImpl to false. For old SocketImpls, the method loop will exit when the SocketImpl class itself is inspected. The code should either stop before the SocketImpl class or check whether the derived-method is abstract or not.

So, SocketImpl classes written for JREs prior to 1.4 (JSR-51) will not work. It appears that this bug was introduced by the fix for Bug 5089488. The bug is not present in the previous update, 1.5.0_06-b05.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to connect an old-style socket.

Compile the example below using the rt.jar from a 1.3 JRE.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should exit without printing anything.
ACTUAL -
Error message as below.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.AbstractMethodError: java.net.SocketImpl.connect(Ljava/net/SocketAddress;I)V
        at java.net.Socket.connect(Socket.java:516)
        at java.net.Socket.connect(Socket.java:466)
        at java.net.Socket.<init>(Socket.java:366)
        at java.net.Socket.<init>(Socket.java:179)
        at OldSocketImpl.main(OldSocketImpl.java:11)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;

class OldSocketImpl extends SocketImpl  {
    public static void main(String[] args) throws Exception {
        Socket.setSocketImplFactory(new SocketImplFactory() {
                public SocketImpl createSocketImpl() {
                    return new OldSocketImpl();
                }
        });
        Socket socket = new Socket("localhost", 23);
    }
    public void setOption(int optID, Object value) throws SocketException { eh(); }
    public Object getOption(int optID) throws SocketException { throw eh(); }



    protected void create(boolean stream) throws IOException { /*eh();*/ }

    protected void connect(String host, int port) throws IOException { eh(); }

    protected void connect(InetAddress address, int port) throws IOException { /*eh();*/ }

// Not in 1.3...
//    protected void connect(SocketAddress address, int timeout) throws IOException { eh(); }

    protected void bind(InetAddress host, int port) throws IOException { /*eh();*/ }
    protected void listen(int backlog) throws IOException { eh(); }

    protected void accept(SocketImpl s) throws IOException { eh(); }

    protected InputStream getInputStream() throws IOException { throw eh(); }

    protected OutputStream getOutputStream() throws IOException { throw eh(); }

    protected int available() throws IOException { throw eh(); }

    protected void close() throws IOException { /*eh();*/ }

    protected void sendUrgentData (int data) throws SocketException { eh(); }
    SocketException eh() throws SocketException { throw new SocketException("Eh?"); }
}
---------- END SOURCE ----------

Release Regression From : 5.0u6
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Release Regression From : 5.0u6
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION The fix is to check the hierarchy up to (not including) java.net.SocketImpl
19-07-2006

EVALUATION This is indeed a regression as a result of the fix for 5089488. 5089488 checks the class inheritance tree to find if a superclass has a connect(InetAddress, int) method. This is incorrect as the SocketImpl class in 1.4+ will have this abstract method even if not implemented in the subclass.
17-07-2006