< prev index next >

src/java.base/windows/classes/java/net/PlainSocketImpl.java

Print this page
rev 49701 : [mq]: 8201510-Merge-TwoStacksPlainSocketImpl-into-DualStackPlainSocketImpl

@@ -23,69 +23,36 @@
  * questions.
  */
 package java.net;
 
 import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import sun.security.action.GetPropertyAction;
 
 /*
  * This class PlainSocketImpl simply delegates to the appropriate real
  * SocketImpl. We do this because PlainSocketImpl is already extended
  * by SocksSocketImpl.
  * <p>
- * There are two possibilities for the real SocketImpl,
- * TwoStacksPlainSocketImpl or DualStackPlainSocketImpl. We use
- * DualStackPlainSocketImpl on systems that have a dual stack
- * TCP implementation. Otherwise we create an instance of
- * TwoStacksPlainSocketImpl and delegate to it.
+ * There is one possibility for the real SocketImpl: DualStackPlainSocketImpl.
  *
  * @author Chris Hegarty
  */
 
 class PlainSocketImpl extends AbstractPlainSocketImpl {
     private AbstractPlainSocketImpl impl;
 
-    /* java.net.preferIPv4Stack */
-    private static final boolean preferIPv4Stack;
-
-    /* True if exclusive binding is on for Windows */
-    private static final boolean exclusiveBind;
-
-    static {
-        preferIPv4Stack = Boolean.parseBoolean(
-        AccessController.doPrivileged(
-                new GetPropertyAction("java.net.preferIPv4Stack")));
-
-        String exclBindProp = AccessController.doPrivileged(
-                new GetPropertyAction("sun.net.useExclusiveBind", ""));
-        exclusiveBind = (exclBindProp.isEmpty())
-                ? true
-                : Boolean.parseBoolean(exclBindProp);
-    }
-
     /**
      * Constructs an empty instance.
      */
     PlainSocketImpl() {
-        if (!preferIPv4Stack) {
-            impl = new DualStackPlainSocketImpl(exclusiveBind);
-        } else {
-            impl = new TwoStacksPlainSocketImpl(exclusiveBind);
-        }
+        impl = new DualStackPlainSocketImpl();
     }
 
     /**
      * Constructs an instance with the given file descriptor.
      */
     PlainSocketImpl(FileDescriptor fd) {
-        if (!preferIPv4Stack) {
-            impl = new DualStackPlainSocketImpl(fd, exclusiveBind);
-        } else {
-            impl = new TwoStacksPlainSocketImpl(fd, exclusiveBind);
-        }
+        impl = new DualStackPlainSocketImpl(fd);
     }
 
     // Override methods in SocketImpl that access impl's fields.
 
     protected FileDescriptor getFileDescriptor() {

@@ -146,22 +113,14 @@
     protected void connect(SocketAddress address, int timeout) throws IOException {
         impl.connect(address, timeout);
     }
 
     public void setOption(int opt, Object val) throws SocketException {
-        if (opt == SocketOptions.SO_REUSEPORT) {
-            // SO_REUSEPORT is not supported on Windows.
-            throw new UnsupportedOperationException("unsupported option");
-        }
         impl.setOption(opt, val);
     }
 
     public Object getOption(int opt) throws SocketException {
-        if (opt == SocketOptions.SO_REUSEPORT) {
-            // SO_REUSEPORT is not supported on Windows.
-            throw new UnsupportedOperationException("unsupported option");
-        }
         return impl.getOption(opt);
     }
 
     synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
         impl.doConnect(address, port, timeout);

@@ -269,12 +228,12 @@
         return impl.getTimeout();
     }
 
     // Override methods in AbstractPlainSocketImpl that need to be implemented.
 
-    void socketCreate(boolean isServer) throws IOException {
-        impl.socketCreate(isServer);
+    void socketCreate(boolean stream) throws IOException {
+        impl.socketCreate(stream);
     }
 
     void socketConnect(InetAddress address, int port, int timeout)
         throws IOException {
         impl.socketConnect(address, port, timeout);

@@ -305,22 +264,14 @@
         impl.socketShutdown(howto);
     }
 
     void socketSetOption(int cmd, boolean on, Object value)
         throws SocketException {
-        if (cmd == SocketOptions.SO_REUSEPORT) {
-            // SO_REUSEPORT is not supported on Windows.
-            throw new UnsupportedOperationException("unsupported option");
-        }
         impl.socketSetOption(cmd, on, value);
     }
 
     int socketGetOption(int opt, Object iaContainerObj) throws SocketException {
-        if (opt == SocketOptions.SO_REUSEPORT) {
-            // SO_REUSEPORT is not supported on Windows.
-            throw new UnsupportedOperationException("unsupported option");
-        }
         return impl.socketGetOption(opt, iaContainerObj);
     }
 
     void socketSendUrgentData(int data) throws IOException {
         impl.socketSendUrgentData(data);
< prev index next >