Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269759

Remove the legacy PlainSocketImpl and PlainDatagramSocketImpl implementation

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 18
    • core-libs
    • None
    • low
    • The old implementations of Socket and DatagramSocket will no longer be accessible as both they, and the mechanisms used to enable them, are to be removed.
    • Java API, System or security property
    • JDK

      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 (JDK 13) provided a simpler and more modern drop-in replacement for the legacy PlainSocketImpl implementation, while JEP 373 (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.

      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 {

            pconcannon Patrick Concannon (Inactive)
            dfuchs Daniel Fuchs
            Alan Bateman, Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: