--- old/src/java.base/windows/classes/java/net/DualStackPlainSocketImpl.java 2018-03-06 12:26:27.714157956 -0800 +++ new/src/java.base/windows/classes/java/net/DualStackPlainSocketImpl.java 2018-03-06 12:26:27.114157956 -0800 @@ -26,22 +26,15 @@ import java.io.IOException; import java.io.FileDescriptor; -import jdk.internal.misc.SharedSecrets; -import jdk.internal.misc.JavaIOFileDescriptorAccess; -/** - * This class defines the plain SocketImpl that is used on Windows platforms - * greater or equal to Windows Vista. These platforms have a dual - * layer TCP/IP stack and can handle both IPv4 and IPV6 through a - * single file descriptor. +/* + * This class defines the plain SocketImpl that is used when + * the System property java.net.preferIPv4Stack is set to false. * * @author Chris Hegarty */ -class DualStackPlainSocketImpl extends AbstractPlainSocketImpl -{ - static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess(); - +class DualStackPlainSocketImpl extends AbstractPlainSocketImpl { // true if this socket is exclusively bound private final boolean exclusiveBind; @@ -83,33 +76,18 @@ } @Override - int socketGetOption(int opt, Object iaContainerObj) throws SocketException { - int nativefd = checkAndReturnNativeFD(); - - // SO_BINDADDR is not a socket option. - if (opt == SO_BINDADDR) { - localAddress(nativefd, (InetAddressContainer)iaContainerObj); - return 0; // return value doesn't matter. - } - // SO_REUSEPORT is not supported on Windows. - if (opt == SO_REUSEPORT) { + int socketGetOption(int opt, Object iaContainerObj) + throws SocketException + { + if (opt == SO_REUSEADDR && exclusiveBind) { + // SO_REUSEADDR emulated when using exclusive bind + return isReuseAddress ? 1 : -1; + } else if (opt == SO_REUSEPORT) { + // SO_REUSEPORT is not supported on Windows. throw new UnsupportedOperationException("unsupported option"); + } else { + return socketNativeGetOption(opt, iaContainerObj); } - - // SO_REUSEADDR emulated when using exclusive bind - if (opt == SO_REUSEADDR && exclusiveBind) - return isReuseAddress? 1 : -1; - - int value = getIntOption(nativefd, opt); - - switch (opt) { - case TCP_NODELAY : - case SO_OOBINLINE : - case SO_KEEPALIVE : - case SO_REUSEADDR : - return (value == 0) ? -1 : 1; - } - return value; } /* Native methods */ @@ -134,9 +112,6 @@ native void socketShutdown(int howto) throws IOException; - static native int getIntOption(int fd, int cmd) throws SocketException; - static native void localAddress(int fd, InetAddressContainer in) throws SocketException; - native void socketNativeSetOption(int cmd, boolean on, Object value) throws SocketException; @@ -144,11 +119,4 @@ throws SocketException; native void socketSendUrgentData(int data) throws IOException; - - private int checkAndReturnNativeFD() throws SocketException { - if (fd == null || !fd.valid()) - throw new SocketException("Socket closed"); - - return fdAccess.get(fd); - } }