JDK-8269759 : Remove the legacy PlainSocketImpl and PlainDatagramSocketImpl implementation
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 18
  • Submitted: 2021-07-01
  • Updated: 2024-03-05
  • Resolved: 2021-07-02
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Remove the legacy implementations of `java.net.SocketImpl` and `java.net.DatagramSocketImpl` and the system properties used to select these implementations. The legacy implementation of `SocketImpl` has not been use by default since JDK 13. The legacy implementation of `DatagramSocketImpl` has not been used by default since JDK 15.

Problem
-------

[JEP 353][1] (JDK 13) provided a simpler and more modern drop-in replacement for the legacy `PlainSocketImpl` implementation, while [JEP 373][2] (JDK 15) did the same for `PlainDatagramSocketImpl`.

`PlainSocketImpl` and `PlainDatagramSocketImpl` represent legacy code maintained alongside the new implementations (discussed above) to allow sufficient time for users to migrate. Mechanisms were put in place to reduce compatibility risks that may have arisen in the form of a JDK-specific properties -- `jdk.net.usePlainSocketImpl` and `jdk.net.usePlainDatagramSocketImpl`, which allowed the user to enable these legacy implementations if they so wished. 
These legacy implementations (and the mechanisms they use to enable them to mitigate compatibility issues) now represent a maintenance burden.

Both JEP 353 and JEP 373 have clearly stated that these legacy implementations might be removed in a future unspecified release.
The point has been reached where we believe that these legacy implementations can be safely removed. 

[1]: https://openjdk.java.net/jeps/353

[2]: https://openjdk.java.net/jeps/373

Solution
--------

Remove legacy implementations of `java.net.SocketImpl` and `java.net.DatagramSocketImpl` from the repo.

Remove the support for the system properties `jdk.net.usePlainSocketImpl` and  `jdk.net.usePlainDatagramSocketImpl`. Setting these properties will have no effect.

Remove the implNote from `java.net.SocketImpl` that documents the system property `jdk.net.usePlainSocketImpl`.

Remove the implNote from  `java.net.DatagramSocketImpl` that documents the system property `jdk.net.usePlainDatagramSocketImpl`.


Specification
-------------



src/java.base/share/classes/java/net/SocketImpl.java

     /**
      * The abstract class {@code SocketImpl} is a common superclass
      * of all classes that actually implement sockets. It is used to
      * create both client and server sockets.
      *
    - * @implNote Client and server sockets created with the {@code Socket} and
    - * {@code SocketServer} public constructors create a system-default
    - * {@code SocketImpl}. The JDK historically used a {@code SocketImpl}
    - * implementation type named "PlainSocketImpl" that has since been replaced by a
    - * newer implementation. The JDK continues to ship with the older implementation
    - * to allow code to run that depends on unspecified behavior that differs between
    - * the old and new implementations. The old implementation will be used if the
    - * Java virtual machine is started with the system property {@systemProperty
    - * jdk.net.usePlainSocketImpl} set to use the old implementation. It may also be
    - * set in the JDK's network configuration file, located in {@code
    - * ${java.home}/conf/net.properties}. The value of the property is the string
    - * representation of a boolean. If set without a value then it defaults to {@code
    - * true}, hence running with {@code -Djdk.net.usePlainSocketImpl} or {@code
    - * -Djdk.net.usePlainSocketImpl=true} will configure the Java virtual machine
    - * to use the old implementation. The property and old implementation will be
    - * removed in a future version.
    - *
      * @since   1.0
      */
     public abstract class SocketImpl implements SocketOptions {


 src/java.base/share/classes/java/net/DatagramSocketImpl.java

     /**
      * Abstract datagram and multicast socket implementation base class.
      *
    - * @implNote Sockets created with the {@code DatagramSocket} and {@code
    - * MulticastSocket} public constructors historically delegated all socket
    - * operations to a {@code DatagramSocketImpl} implementation named
    - * "PlainDatagramSocketImpl". {@code DatagramSocket} and {@code MulticastSocket}
    - * have since been changed to a new implementation based on {@code DatagramChannel}.
    - * The JDK continues to ship with the older implementation to allow code to run
    - * that depends on unspecified behavior that differs between the old and new
    - * implementations. The old implementation will be used if the Java virtual
    - * machine is started with the system property {@systemProperty
    - * jdk.net.usePlainDatagramSocketImpl} set to use the old implementation. It may
    - * also be set in the JDK's network configuration file, located in {@code
    - * ${java.home}/conf/net.properties}. The value of the property is the string
    - * representation of a boolean. If set without a value then it defaults to {@code
    - * true}, hence running with {@code -Djdk.net.usePlainDatagramSocketImpl} or
    - * {@code -Djdk.net.usePlainDatagramSocketImpl=true} will configure the Java
    - * virtual machine to use the old implementation. The property and old
    - * implementation will be removed in a future version.
    - *
      * @author Pavani Diwanji
      * @since  1.1
      */
    
     public abstract class DatagramSocketImpl implements SocketOptions {


Comments
Moving to Approved.
02-07-2021

The new implementations have had several releases to bed in and I don't think we've seen any bug reports or usages of these properties. So I think this is a low risk change. A release note is planned.
01-07-2021