United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6449565 Pre-1.4 SocketImpl no longer supported
JDK-6449565 : Pre-1.4 SocketImpl no longer supported

Details
Type:
Bug
Submit Date:
2006-07-17
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2006-08-05
Component:
core-libs
OS:
linux
Sub-Component:
java.net
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Backport:
Backport:
Relates:
Relates:

Sub Tasks

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

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.
                                     
2006-07-17
EVALUATION

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



Hardware and Software, Engineered to Work Together