partial cleanup unixdomainchannels
authormichaelm
Tue, 29 Oct 2019 19:23:09 +0000
branchunixdomainchannels
changeset 58847 692de65ab293
parent 58832 203fceb089fc
child 58848 c3df0f8b6d93
partial cleanup
src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java
src/java.base/share/classes/java/nio/channels/SocketChannel.java
src/java.base/share/classes/java/nio/channels/UnixDomainSocketAddress.java
src/java.base/share/classes/sun/net/util/SocketExceptions.java
src/java.base/share/classes/sun/nio/ch/Net.java
src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java
src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java
src/java.base/share/native/libnet/net_util.h
src/java.base/share/native/libnio/ch/UnixDomainSocketAddress.c
src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java
src/java.base/unix/native/libnio/ch/Net.c
src/java.base/unix/native/libnio/ch/nio_util.h
src/java.base/windows/native/libnio/ch/IOUtil.c
src/java.base/windows/native/libnio/ch/Net.c
--- a/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java	Tue Oct 29 19:23:09 2019 +0000
@@ -186,9 +186,9 @@
      * @throws  SecurityException
      *          If a security manager has been installed and its
      *          {@link SecurityManager#checkListen checkListen} method denies
-     *          the operation for <i>IP</i> channels or for <i>unix domain</i>
+     *          the operation for <i>IP</i> channels. Or with <i>unix domain</i>
      *          channels, if the security manager denies "read" or "write"
-     *          {@link FilePermission} for the local path.
+     *          {@link java.io.FilePermission} for the local path.
      *
      * @since 1.7
      */
@@ -214,9 +214,9 @@
      * default is used.
      *
      * <p> Note, for <i>Unix domain</i> channels, a file is created in the file-system
-     * with the same name as this channel's bound address. This file persists after
-     * the channel is closed, and must be removed before another channel can bind
-     * to the same name.
+     * with the same path name as this channel's bound {@link UnixDomainSocketAddress}.
+     * This file persists after the channel is closed, and must be removed before
+     * another channel can bind to the same name.
      *
      * @param   local
      *          The address to bind the socket, or {@code null} to bind to an
@@ -237,9 +237,9 @@
      * @throws  SecurityException
      *          If a security manager has been installed and its
      *          {@link SecurityManager#checkListen checkListen} method denies
-     *          the operation for <i>IP</i> channels or for <i>unix domain</i>
+     *          the operation for <i>IP</i> channels. Or with <i>unix domain</i>
      *          channels, if the security manager denies "read" or "write"
-     *          {@link FilePermission} for the local path.
+     *          {@link java.io.FilePermission} for the local path.
      *
      * @since 1.7
      */
@@ -265,7 +265,7 @@
      * declared in the {@link java.net.ServerSocket} class.  </p>
      *
      * @return  A server socket associated with this channel
-     * @throws UnsupportedOperationException is this is a Unix domain channel
+     * @throws UnsupportedOperationException if this is a Unix domain channel
      */
     public abstract ServerSocket socket();
 
@@ -280,8 +280,8 @@
      * <p> The socket channel returned by this method, if any, will be in
      * blocking mode regardless of the blocking mode of this channel.
      *
-     * <p> For <i>IP</i> channels, this method performs exactly the same security checks as the {@link
-     * java.net.ServerSocket#accept accept} method of the {@link
+     * <p> For <i>IP</i> channels, this method performs exactly the same security checks
+     * as the {@link java.net.ServerSocket#accept accept} method of the {@link
      * java.net.ServerSocket} class.  That is, if a security manager has been
      * installed then for each new connection this method verifies that the
      * address and port number of the connection's remote endpoint are
@@ -325,6 +325,8 @@
 
     /**
      * {@inheritDoc}
+     * Where the channel is bound to a <i>Unix domain</i> address, the return
+     * value from this this method is of type  {@link UnixDomainSocketAddress}.
      * <p>
      * If there is a security manager set and this is an <i>IP</i> channel,
      * {@code checkConnect} method is
@@ -334,9 +336,12 @@
      * {@link java.net.InetAddress#getLoopbackAddress loopback} address and the
      * local port of the channel's socket is returned.
      * <p>
-     * If there is a security manager set and this is an <i>unix domain</i> channel,
-     * then this returns a {@link UnixDomainSocketAddress} corresponding to the
-     * bound address.
+     * If there is a security manager set and this is a <i>unix domain</i> channel,
+     * then {@link SecurityManager#checkPermission(Permission)} is called using
+     * a {@link java.io.FilePermission} constructed with the path from the
+     * local address and "read" as the action. If this check fails
+     * then an unnamed {@link UnixDomainSocketAddress} (with empty pathname)
+     * is returned.
      *
      * @return  The {@code SocketAddress} that the socket is bound to, or the
      *          {@code SocketAddress} representing the loopback address if
--- a/src/java.base/share/classes/java/nio/channels/SocketChannel.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/java/nio/channels/SocketChannel.java	Tue Oct 29 19:23:09 2019 +0000
@@ -116,7 +116,6 @@
  * </tbody>
  * </table>
  * </blockquote>
- *
  * Additional (implementation specific) options may also be supported.
  *
  * <p> Socket channels are safe for use by multiple concurrent threads.  They
@@ -290,7 +289,7 @@
      *          {@link SecurityManager#checkListen checkListen} method denies
      *          the operation for <i>IP</i> channels or for <i>unix domain</i>
      *          channels, if the security manager denies "read" or "write"
-     *          {@link FilePermission} for the local path.
+     *          {@link java.io.FilePermission} for the local path.
      *
      * @since 1.7
      */
--- a/src/java.base/share/classes/java/nio/channels/UnixDomainSocketAddress.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/java/nio/channels/UnixDomainSocketAddress.java	Tue Oct 29 19:23:09 2019 +0000
@@ -36,8 +36,8 @@
  * addresses contain a String path name, which when bound to a channel,
  * have an associated file in the file-system with the same name.
  * <p>
- * If a channel is automatically bound to Unix domain address then its address
- * is unnamed, has an empty path field, and therefore has no associated
+ * If a channel is automatically bound to a Unix domain address then its address
+ * is unnamed; it has an empty path field, and therefore has no associated
  * file in the file-system.
  * <p>
  * Note, not all channel types support Unix domain addresses.
--- a/src/java.base/share/classes/sun/net/util/SocketExceptions.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/net/util/SocketExceptions.java	Tue Oct 29 19:23:09 2019 +0000
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.net.InetSocketAddress;
+import java.nio.channels.UnixDomainSocketAddress;
 import java.net.SocketAddress;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -53,8 +54,11 @@
      * Only specific IOException subtypes are supported.
      */
     public static IOException of(IOException e, SocketAddress addr) {
+        if (addr instanceof UnixDomainSocketAddress)
+            return ofUnixDomain(e, (UnixDomainSocketAddress)addr);
         if (!(addr instanceof InetSocketAddress))
             return e;
+
         InetSocketAddress address = (InetSocketAddress)addr;
         if (!enhancedExceptionText || address == null)
             return e;
@@ -70,6 +74,18 @@
         return create(e, enhancedMsg);
     }
 
+    private static IOException ofUnixDomain(IOException e, UnixDomainSocketAddress addr) {
+        if (!enhancedExceptionText || addr == null)
+            return e;
+        String path = addr.getPath();
+        StringBuilder sb = new StringBuilder();
+        sb.append(e.getMessage());
+        sb.append(": ");
+        sb.append(path);
+        String enhancedMsg = sb.toString();
+        return create(e, enhancedMsg);
+    }
+
     // return a new instance of the same type with the given detail
     // msg, or if the type doesn't support detail msgs, return given
     // instance.
--- a/src/java.base/share/classes/sun/nio/ch/Net.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java	Tue Oct 29 19:23:09 2019 +0000
@@ -26,6 +26,7 @@
 package sun.nio.ch;
 
 import java.io.FileDescriptor;
+import java.io.FilePermission;
 import java.io.IOException;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
@@ -57,28 +58,18 @@
 
 public class Net {
 
-    public Net() { }
+    private Net() { }
 
-    private static final boolean unixDomainSupported;
-    //private static final boolean abstractNamesSupported;
+    private static final boolean unixDomainSupported =
+        unixDomainSocketSupported();
 
     // unspecified protocol family
-    public static final ProtocolFamily UNSPEC = new ProtocolFamily() {
+    static final ProtocolFamily UNSPEC = new ProtocolFamily() {
         public String name() {
             return "UNSPEC";
         }
     };
 
-    static {
-        unixDomainSupported = unixDomainSocketSupported();
-        String name = GetPropertyAction.privilegedGetProperty("os.name")
-            .toLowerCase();
-
-        // Windows claims to support it but doesn't. Disable for now
-        //abstractNamesSupported = name.startsWith("linux");
-            //  || name.startsWith("windows");
-    }
-
     // set to true if exclusive binding is on for Windows
     private static final boolean exclusiveBind;
 
@@ -117,7 +108,7 @@
     /**
      * Returns true if exclusive binding is on
      */
-    public static boolean useExclusiveBind() {
+    static boolean useExclusiveBind() {
         return exclusiveBind;
     }
 
@@ -326,13 +317,13 @@
     static final ExtendedSocketOptions extendedOptions =
             ExtendedSocketOptions.getInstance();
 
-    public static void setSocketOption(FileDescriptor fd, SocketOption<?> name, Object value)
+    static void setSocketOption(FileDescriptor fd, SocketOption<?> name, Object value)
         throws IOException
     {
         setSocketOption(fd, Net.UNSPEC, name, value);
     }
 
-    public static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
+    static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
                                 SocketOption<?> name, Object value)
         throws IOException
     {
@@ -394,13 +385,13 @@
         setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6);
     }
 
-    public static Object getSocketOption(FileDescriptor fd, SocketOption<?> name)
+    static Object getSocketOption(FileDescriptor fd, SocketOption<?> name)
         throws IOException
     {
         return getSocketOption(fd, Net.UNSPEC, name);
     }
 
-    public static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, SocketOption<?> name)
+    static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, SocketOption<?> name)
         throws IOException
     {
         Class<?> type = name.type();
@@ -459,7 +450,7 @@
         return IOUtil.newFD(socket0(preferIPv6, stream, false, fastLoopback));
     }
 
-    public static FileDescriptor serverSocket(boolean stream) {
+    static FileDescriptor serverSocket(boolean stream) {
         return IOUtil.newFD(socket0(isIPv6Available(), stream, true, fastLoopback));
     }
 
@@ -489,7 +480,7 @@
                                      int port)
         throws IOException;
 
-    public static native void listen(FileDescriptor fd, int backlog) throws IOException;
+    static native void listen(FileDescriptor fd, int backlog) throws IOException;
 
     static int connect(FileDescriptor fd, InetAddress remote, int remotePort)
         throws IOException
@@ -523,7 +514,7 @@
     public static final int SHUT_WR = 1;
     public static final int SHUT_RDWR = 2;
 
-    public static native void shutdown(FileDescriptor fd, int how) throws IOException;
+    static native void shutdown(FileDescriptor fd, int how) throws IOException;
 
     private static native int localPort(FileDescriptor fd)
         throws IOException;
@@ -590,14 +581,14 @@
      *
      * @return true if connected
      */
-    public static boolean pollConnectNow(FileDescriptor fd) throws IOException {
+    static boolean pollConnectNow(FileDescriptor fd) throws IOException {
         return pollConnect(fd, 0);
     }
 
     /**
      * Return the number of bytes in the socket input buffer.
      */
-    public static native int available(FileDescriptor fd) throws IOException;
+    static native int available(FileDescriptor fd) throws IOException;
 
     /**
      * Send one byte of urgent data (MSG_OOB) on the socket.
@@ -709,30 +700,40 @@
     public static final short POLLIN;
     public static final short POLLOUT;
 
-    public static boolean isUnixDomainSupported() {
-        return unixDomainSupported;
-    }
-
     public static UnixDomainSocketAddress checkUnixAddress(SocketAddress sa) {
         if (sa == null)
             throw new NullPointerException();
         if (!(sa instanceof UnixDomainSocketAddress))
             throw new UnsupportedAddressTypeException();
         UnixDomainSocketAddress usa = (UnixDomainSocketAddress)sa;
-        //if (usa.isAbstract() && !abstractNamesSupported())
-            //throw new UnsupportedAddressTypeException();
         return usa;
     }
 
-    /**
-     * 2 methods to be implemented if fine-grained security to be used
-     */
+    public static boolean isUnixDomainSupported() {
+        return unixDomainSupported;
+    }
+
+    private static UnixDomainSocketAddress UNNAMED = new UnixDomainSocketAddress("");
+
     static UnixDomainSocketAddress getRevealedLocalAddress(UnixDomainSocketAddress addr) {
+        SecurityManager sm = System.getSecurityManager();
+        if (addr == null || sm == null)
+            return addr;
+
+        try{
+            FilePermission p = new FilePermission(addr.getPath(), "read");
+            sm.checkPermission(p);
+            // Security check passed
+        } catch (SecurityException e) {
+            // Return unnamed address only if security check fails
+            addr = UNNAMED;
+        }
         return addr;
     }
 
     static String getRevealedLocalAddressAsString(UnixDomainSocketAddress addr) {
-        return addr.toString();
+        return System.getSecurityManager() == null ? addr.toString() :
+                UNNAMED.toString();
     }
 
     // -- Socket operations --
@@ -741,9 +742,9 @@
         return IOUtil.newFD(unixDomainSocket0());
     }
 
-    public static native boolean unixDomainSocketSupported();
+    private static native int unixDomainSocket0();
 
-    private static native int unixDomainSocket0();
+    private static native boolean unixDomainSocketSupported();
 
     static native void unixDomainBind(FileDescriptor fd, UnixDomainSocketAddress addr)
         throws IOException;
@@ -801,6 +802,4 @@
 
         fastLoopback = isFastTcpLoopbackRequested();
     }
-
-
 }
--- a/src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java	Tue Oct 29 19:23:09 2019 +0000
@@ -66,7 +66,7 @@
         if (family == StandardProtocolFamily.INET || family == StandardProtocolFamily.INET6) {
             throw new UnsupportedOperationException("This will be supported, but is not implemented yet");
             //return new InetSocketChannelImpl(this);
-        } else if (family == StandardProtocolFamily.UNIX) {
+        } else if (family == StandardProtocolFamily.UNIX && Net.isUnixDomainSupported()) {
             return new UnixDomainSocketChannelImpl(this, Net.unixDomainSocket(), false);
         } else
             throw new UnsupportedAddressTypeException();
@@ -77,7 +77,7 @@
         if (family == StandardProtocolFamily.INET || family == StandardProtocolFamily.INET6) {
             throw new UnsupportedOperationException("This will be supported, but is not implemented yet");
             //return new InetServerSocketChannelImpl(this);
-        } else if (family == StandardProtocolFamily.UNIX) {
+        } else if (family == StandardProtocolFamily.UNIX && Net.isUnixDomainSupported()) {
             return new UnixDomainServerSocketChannelImpl(this);
         } else
             throw new UnsupportedAddressTypeException();
--- a/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Tue Oct 29 19:23:09 2019 +0000
@@ -55,7 +55,7 @@
  * An implementation of ServerSocketChannels
  */
 
-public abstract class ServerSocketChannelImpl
+abstract class ServerSocketChannelImpl
     extends ServerSocketChannel
     implements SelChImpl
 {
--- a/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	Tue Oct 29 19:23:09 2019 +0000
@@ -64,7 +64,7 @@
  * An implementation of SocketChannels
  */
 
-public abstract class SocketChannelImpl
+abstract class SocketChannelImpl
     extends SocketChannel
     implements SelChImpl
 {
@@ -118,13 +118,13 @@
 
     // Constructor for normal connecting sockets
     //
-    public SocketChannelImpl(SelectorProvider sp) throws IOException {
+    SocketChannelImpl(SelectorProvider sp) throws IOException {
         super(sp);
         this.fd = Net.socket(true);
         this.fdVal = IOUtil.fdVal(fd);
     }
 
-    public SocketChannelImpl(SelectorProvider sp, FileDescriptor fd)
+    SocketChannelImpl(SelectorProvider sp, FileDescriptor fd)
         throws IOException
     {
         super(sp);
@@ -765,13 +765,6 @@
         }
     }
 
-    /**
-     * Package private version called from InheritedChannel
-     */
-    void localImplCloseSelectableChannel() throws IOException {
-        implCloseSelectableChannel();
-    }
-
     @Override
     public SocketChannel shutdownInput() throws IOException {
         synchronized (stateLock) {
--- a/src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/UnixDomainSocketChannelImpl.java	Tue Oct 29 19:23:09 2019 +0000
@@ -78,16 +78,6 @@
         }
     }
 
-/*
-    public static AbstractSocketChannelImpl create(SelectorProvider sp, FileDescriptor fd) {
-        try {
-            return new UnixDomainSocketChannelImpl(sp, fd, false);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-*/
-
     // Constructor for sockets obtained from server sockets
     //
     UnixDomainSocketChannelImpl(SelectorProvider sp, FileDescriptor fd, SocketAddress isa)
--- a/src/java.base/share/native/libnet/net_util.h	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/native/libnet/net_util.h	Tue Oct 29 19:23:09 2019 +0000
@@ -118,7 +118,6 @@
 extern jclass udsa_class;
 extern jmethodID udsa_ctorID;
 extern jfieldID udsa_pathID;
-extern jfieldID udsa_isAbstractID;
 
 /************************************************************************
  *  Utilities
--- a/src/java.base/share/native/libnio/ch/UnixDomainSocketAddress.c	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/share/native/libnio/ch/UnixDomainSocketAddress.c	Tue Oct 29 19:23:09 2019 +0000
@@ -35,7 +35,6 @@
 jclass udsa_class;
 jmethodID udsa_ctorID;
 jfieldID udsa_pathID;
-//jfieldID udsa_isAbstractID;
 
 static int udsa_initialized = 0;
 
@@ -55,9 +54,6 @@
         udsa_pathID = (*env)->GetFieldID(env, udsa_class, "path", "Ljava/lang/String;");
         CHECK_NULL(udsa_pathID);
 
-        //udsa_isAbstractID = (*env)->GetFieldID(env, udsa_class, "isAbstract", "Z");
-        //CHECK_NULL(udsa_isAbstractID);
-
         udsa_ctorID = (*env)->GetMethodID(env, udsa_class, "<init>", "(Ljava/lang/String;)V");
         CHECK_NULL(udsa_ctorID);
 
--- a/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java	Tue Oct 29 19:23:09 2019 +0000
@@ -40,10 +40,8 @@
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.spi.SelectorProvider;
-import java.util.Set;
-import java.util.function.BiFunction;
 
-public class InheritedChannel {
+class InheritedChannel {
 
     // the "types" of socket returned by soType0
     private static final int UNKNOWN            = -1;
@@ -112,7 +110,7 @@
 
         @Override
         protected void implCloseSelectableChannel() throws IOException {
-            super.localImplCloseSelectableChannel();
+            super.implCloseSelectableChannel();
             detachIOStreams();
         }
     }
--- a/src/java.base/unix/native/libnio/ch/Net.c	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/unix/native/libnio/ch/Net.c	Tue Oct 29 19:23:09 2019 +0000
@@ -50,7 +50,6 @@
 extern jclass udsa_class;
 extern jmethodID udsa_ctorID;
 extern jfieldID udsa_pathID;
-extern jfieldID udsa_isAbstractID;
 
 JNIEXPORT jobject JNICALL
 NET_SockaddrToUnixAddress(JNIEnv *env, SOCKETADDRESS *sa) {
@@ -59,14 +58,6 @@
     if (sa->sa.sa_family == AF_UNIX) {
         char *name = sa->saun.sun_path;
 
-#ifdef NOTDEF
-        /* check for abstract name */
-        if (name[0] == 0) {
-            isAbstract = 1;
-            name++; // skip the zero byte
-        } else
-            isAbstract = 0;
-#endif
         jstring nstr = JNU_NewStringPlatform(env, name);
         return (*env)->NewObject(env, udsa_class, udsa_ctorID, nstr);
     }
@@ -77,7 +68,6 @@
 NET_UnixSocketAddressToSockaddr(JNIEnv *env, jobject uaddr, SOCKETADDRESS *sa, int *len)
 {
     jstring path = (*env)->GetObjectField(env, uaddr, udsa_pathID);
-    //jboolean isAbstract = (*env)->GetBooleanField(env, uaddr, udsa_isAbstractID);
     jboolean isCopy;
     int ret;
     const char* pname = JNU_GetStringPlatformChars(env, path, &isCopy);
@@ -89,16 +79,7 @@
         ret = 1;
         goto finish;
     }
-#ifdef NOTDEF
-    if (isAbstract) {
-        strncpy(&sa->saun.sun_path[1], pname, name_len);
-        sa->saun.sun_path[0] = 0;
-        name_len++;
-    } else
-#endif
-    {
-        strncpy(&sa->saun.sun_path[0], pname, name_len);
-    }
+    strncpy(&sa->saun.sun_path[0], pname, name_len);
     *len = offsetof(struct sockaddr_un, sun_path) + name_len;
     ret = 0;
   finish:
@@ -107,6 +88,12 @@
     return ret;
 }
 
+JNIEXPORT jboolean JNICALL
+Java_sun_nio_ch_Net_unixDomainSocketSupported(JNIEnv *env, jclass cl)
+{
+    return JNI_TRUE;
+}
+
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_Net_unixDomainSocket0(JNIEnv *env, jclass cl)
 {
@@ -117,17 +104,6 @@
     return fd;
 }
 
-JNIEXPORT jboolean JNICALL
-Java_sun_nio_ch_Net_unixDomainSocketSupported(JNIEnv *env, jclass cl)
-{
-    int fd = socket(PF_UNIX, SOCK_STREAM, 0);
-    if (fd < 0) {
-        return JNI_FALSE;
-    }
-    close(fd);
-    return JNI_TRUE;
-}
-
 JNIEXPORT void JNICALL
 Java_sun_nio_ch_Net_unixDomainBind(JNIEnv *env, jclass clazz, jobject fdo, jobject uaddr)
 {
@@ -222,6 +198,7 @@
     }
     return NET_SockaddrToUnixAddress(env, &sa);
 }
+
 /**
  * IP_MULTICAST_ALL supported since 2.6.31 but may not be available at
  * build time.
@@ -1043,8 +1020,7 @@
 
 /* Declared in nio_util.h */
 
-JNIEXPORT jint JNICALL
-handleSocketError(JNIEnv *env, jint errorValue)
+jint handleSocketError(JNIEnv *env, jint errorValue)
 {
     char *xn;
     switch (errorValue) {
--- a/src/java.base/unix/native/libnio/ch/nio_util.h	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/unix/native/libnio/ch/nio_util.h	Tue Oct 29 19:23:09 2019 +0000
@@ -54,11 +54,9 @@
 
 /* Defined in IOUtil.c */
 
-JNIEXPORT jint JNICALL
-fdval(JNIEnv *env, jobject fdo);
+jint fdval(JNIEnv *env, jobject fdo);
 
-JNIEXPORT void JNICALL
-setfdval(JNIEnv *env, jobject fdo, jint value);
+void setfdval(JNIEnv *env, jobject fdo, jint value);
 
 jint convertReturnVal(JNIEnv *env, jint n, jboolean reading);
 jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean reading);
@@ -66,5 +64,4 @@
 
 /* Defined in Net.c */
 
-JNIEXPORT jint JNICALL
-handleSocketError(JNIEnv *env, jint errorValue);
+jint handleSocketError(JNIEnv *env, jint errorValue);
--- a/src/java.base/windows/native/libnio/ch/IOUtil.c	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/windows/native/libnio/ch/IOUtil.c	Tue Oct 29 19:23:09 2019 +0000
@@ -192,14 +192,12 @@
 /* Note: This function returns the int fd value from file descriptor.
    It is mostly used for sockets which should use the int fd value.
 */
-JNIEXPORT jint JNICALL
-fdval(JNIEnv *env, jobject fdo)
+jint fdval(JNIEnv *env, jobject fdo)
 {
     return (*env)->GetIntField(env, fdo, fd_fdID);
 }
 
-JNIEXPORT void JNICALL
-setfdval(JNIEnv *env, jobject fdo, jint val)
+void setfdval(JNIEnv *env, jobject fdo, jint val)
 {
     (*env)->SetIntField(env, fdo, fd_fdID, val);
 }
--- a/src/java.base/windows/native/libnio/ch/Net.c	Tue Oct 29 08:26:48 2019 +0000
+++ b/src/java.base/windows/native/libnio/ch/Net.c	Tue Oct 29 19:23:09 2019 +0000
@@ -77,8 +77,7 @@
              NULL, 0, &bytesReturned, NULL, NULL);
 }
 
-JNIEXPORT jint JNICALL
-handleSocketError(JNIEnv *env, int errorValue)
+jint handleSocketError(JNIEnv *env, int errorValue)
 {
     NET_ThrowNew(env, errorValue, NULL);
     return IOS_THROWN;
@@ -90,23 +89,13 @@
 extern jclass udsa_class;
 extern jmethodID udsa_ctorID;
 extern jfieldID udsa_pathID;
-extern jfieldID udsa_isAbstractID;
 
 JNIEXPORT jobject JNICALL
 NET_SockaddrToUnixAddress(JNIEnv *env, SOCKETADDRESS *sa) {
-    jboolean isAbstract;
 
     if (sa->sa.sa_family == AF_UNIX) {
         char *name = sa->saun.sun_path;
 
-#ifdef NOTDEF
-        /* check for abstract name */
-        if (name[0] == 0) {
-            isAbstract = 1;
-            name++; // skip the zero byte
-        } else
-#endif
-            isAbstract = 0;
         jstring nstr = JNU_NewStringPlatform(env, name);
         return (*env)->NewObject(env, udsa_class, udsa_ctorID, nstr);
     }
@@ -118,7 +107,6 @@
 {
     jstring path = (*env)->GetObjectField(env, uaddr, udsa_pathID);
     jboolean isCopy;
-    //jboolean isAbstract = (*env)->GetBooleanField(env, uaddr, udsa_isAbstractID);
     int ret;
     const char* pname = JNU_GetStringPlatformChars(env, path, &isCopy);
     memset(sa, 0, sizeof(SOCKETADDRESS));
@@ -129,16 +117,7 @@
         ret = 1;
         goto finish;
     }
-#ifdef NOTDEF
-    if (isAbstract) {
-        strncpy(&sa->saun.sun_path[1], pname, name_len);
-        sa->saun.sun_path[0] = 0;
-        name_len++;
-    } else
-#endif
-    {
-        strncpy(sa->saun.sun_path, pname, name_len);
-    }
+    strncpy(sa->saun.sun_path, pname, name_len);
     *len = (int)(offsetof(struct sockaddr_un, sun_path) + name_len);
     ret = 0;
   finish: