8034174: Remove use of JVM_* functions from java.net code
authorchegar
Tue, 25 Feb 2014 12:35:14 +0000
changeset 23015 73b21ab36615
parent 23014 af8145529dd4
child 23019 e657f2692600
8034174: Remove use of JVM_* functions from java.net code Reviewed-by: alanb, dsamersoff, michaelm
jdk/make/lib/NetworkingLibraries.gmk
jdk/src/aix/native/java/net/aix_close.c
jdk/src/share/native/java/net/net_util.c
jdk/src/share/native/java/net/net_util.h
jdk/src/solaris/native/java/net/Inet4AddressImpl.c
jdk/src/solaris/native/java/net/Inet6AddressImpl.c
jdk/src/solaris/native/java/net/NetworkInterface.c
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
jdk/src/solaris/native/java/net/PlainSocketImpl.c
jdk/src/solaris/native/java/net/SocketInputStream.c
jdk/src/solaris/native/java/net/SocketOutputStream.c
jdk/src/solaris/native/java/net/bsd_close.c
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/solaris/native/java/net/net_util_md.c
jdk/src/solaris/native/java/net/net_util_md.h
jdk/src/solaris/native/java/net/solaris_close.c
jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
jdk/src/windows/native/java/net/Inet4AddressImpl.c
jdk/src/windows/native/java/net/Inet6AddressImpl.c
jdk/src/windows/native/java/net/SocketInputStream.c
jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c
--- a/jdk/make/lib/NetworkingLibraries.gmk	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/make/lib/NetworkingLibraries.gmk	Tue Feb 25 12:35:14 2014 +0000
@@ -38,6 +38,10 @@
 LIBNET_CFLAGS := $(foreach dir, $(LIBNET_SRC_DIRS), -I$(dir))
 
 LIBNET_EXCLUDE_FILES :=
+ifneq ($(OPENJDK_TARGET_OS), solaris)
+  LIBNET_EXCLUDE_FILES += solaris_close.c
+endif
+
 ifneq ($(OPENJDK_TARGET_OS), linux)
   LIBNET_EXCLUDE_FILES += linux_close.c
 endif
--- a/jdk/src/aix/native/java/net/aix_close.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/aix/native/java/net/aix_close.c	Tue Feb 25 12:35:14 2014 +0000
@@ -38,6 +38,18 @@
  * (see aix_close_init).
  *
  */
+
+/*
+   AIX needs a workaround for I/O cancellation, see:
+   http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm
+   ...
+   The close subroutine is blocked until all subroutines which use the file
+   descriptor return to usr space. For example, when a thread is calling close
+   and another thread is calling select with the same file descriptor, the
+   close subroutine does not return until the select call returns.
+   ...
+*/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
--- a/jdk/src/share/native/java/net/net_util.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/share/native/java/net/net_util.c	Tue Feb 25 12:35:14 2014 +0000
@@ -46,13 +46,10 @@
     jstring s;
     jint preferIPv4Stack;
 
-    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2) == JNI_OK) {
-        if (JVM_InitializeSocketLibrary() < 0) {
-            JNU_ThrowByName(env, "java/lang/UnsatisfiedLinkError",
-                            "failed to initialize net library.");
-            return JNI_VERSION_1_2;
-        }
+    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_2) != JNI_OK) {
+        return JNI_EVERSION; /* JNI version not supported */
     }
+
     iCls = (*env)->FindClass(env, "java/lang/Boolean");
     CHECK_NULL_RETURN(iCls, JNI_VERSION_1_2);
     mid = (*env)->GetStaticMethodID(env, iCls, "getBoolean", "(Ljava/lang/String;)Z");
--- a/jdk/src/share/native/java/net/net_util.h	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/share/native/java/net/net_util.h	Tue Feb 25 12:35:14 2014 +0000
@@ -165,7 +165,7 @@
 
 /* Socket operations
  *
- * These work just like the JVM_* procedures, except that they may do some
+ * These work just like the system calls, except that they may do some
  * platform-specific pre/post processing of the arguments and/or results.
  */
 
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -70,7 +70,7 @@
     char hostname[NI_MAXHOST+1];
 
     hostname[0] = '\0';
-    if (JVM_GetHostName(hostname, NI_MAXHOST)) {
+    if (gethostname(hostname, NI_MAXHOST)) {
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
@@ -332,7 +332,7 @@
     char hostname[NI_MAXHOST+1];
 
     hostname[0] = '\0';
-    if (JVM_GetHostName(hostname, sizeof(hostname))) {
+    if (gethostname(hostname, NI_MAXHOST)) {
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
@@ -729,7 +729,7 @@
      * Let's try to create a RAW socket to send ICMP packets
      * This usually requires "root" privileges, so it's likely to fail.
      */
-    fd = JVM_Socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+    fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
     if (fd != -1) {
       /*
        * It didn't fail, so we can use ICMP_ECHO requests.
@@ -740,8 +740,8 @@
     /*
      * Can't create a raw socket, so let's try a TCP socket
      */
-    fd = JVM_Socket(AF_INET, SOCK_STREAM, 0);
-    if (fd == JVM_IO_ERR) {
+    fd = socket(AF_INET, SOCK_STREAM, 0);
+    if (fd == -1) {
         /* note: if you run out of fds, you may not be able to load
          * the exception class, and get a NoClassDefFoundError
          * instead.
@@ -769,9 +769,8 @@
      */
     SET_NONBLOCKING(fd);
 
-    /* no need to use NET_Connect as non-blocking */
     him.sin_port = htons(7);    /* Echo */
-    connect_rv = JVM_Connect(fd, (struct sockaddr *)&him, len);
+    connect_rv = NET_Connect(fd, (struct sockaddr *)&him, len);
 
     /**
      * connection established or refused immediately, either way it means
@@ -781,7 +780,7 @@
         close(fd);
         return JNI_TRUE;
     } else {
-        int optlen;
+        socklen_t optlen = (socklen_t)sizeof(connect_rv);
 
         switch (errno) {
         case ENETUNREACH: /* Network Unreachable */
@@ -811,9 +810,8 @@
         timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
         if (timeout >= 0) {
           /* has connection been established? */
-          optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = errno;
           }
           if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -70,8 +70,8 @@
     char hostname[NI_MAXHOST+1];
 
     hostname[0] = '\0';
-    ret = JVM_GetHostName(hostname, sizeof(hostname));
-    if (ret) {
+    ret = gethostname(hostname, NI_MAXHOST);
+    if (ret == -1) {
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
@@ -140,7 +140,7 @@
      * the name (if the name actually matches something in DNS etc.
      */
     myhostname[0] = '\0';
-    if (JVM_GetHostName(myhostname, NI_MAXHOST)) {
+    if (gethostname(myhostname, NI_MAXHOST) == -1) {
         /* Something went wrong, maybe networking is not setup? */
         return NULL;
     }
@@ -711,15 +711,15 @@
      * or the echo service has been disabled.
      */
 
-    fd = JVM_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
+    fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
 
     if (fd != -1) { /* Good to go, let's do a ping */
         return ping6(env, fd, &him6, timeout, netif, ttl);
     }
 
     /* No good, let's fall back on TCP */
-    fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0);
-    if (fd == JVM_IO_ERR) {
+    fd = socket(AF_INET6, SOCK_STREAM, 0);
+    if (fd == -1) {
         /* note: if you run out of fds, you may not be able to load
          * the exception class, and get a NoClassDefFoundError
          * instead.
@@ -743,9 +743,8 @@
     }
     SET_NONBLOCKING(fd);
 
-    /* no need to use NET_Connect as non-blocking */
     him6.sin6_port = htons((short) 7); /* Echo port */
-    connect_rv = JVM_Connect(fd, (struct sockaddr *)&him6, len);
+    connect_rv = NET_Connect(fd, (struct sockaddr *)&him6, len);
 
     /**
      * connection established or refused immediately, either way it means
@@ -755,7 +754,7 @@
         close(fd);
         return JNI_TRUE;
     } else {
-        int optlen;
+        socklen_t optlen = (socklen_t)sizeof(connect_rv);
 
         switch (errno) {
         case ENETUNREACH: /* Network Unreachable */
@@ -786,9 +785,8 @@
 
         if (timeout >= 0) {
           /* has connection been established */
-          optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = errno;
           }
           if (connect_rv == 0 || ECONNREFUSED) {
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Tue Feb 25 12:35:14 2014 +0000
@@ -1014,7 +1014,7 @@
 static int  openSocket(JNIEnv *env, int proto){
     int sock;
 
-    if ((sock = JVM_Socket(proto, SOCK_DGRAM, 0)) < 0) {
+    if ((sock = socket(proto, SOCK_DGRAM, 0)) < 0) {
         /*
          * If EPROTONOSUPPORT is returned it means we don't have
          * support  for this proto so don't throw an exception.
@@ -1040,9 +1040,9 @@
     int sock;
     struct ifreq if2;
 
-     if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+     if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
          if (errno == EPROTONOSUPPORT){
-              if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
+              if ( (sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
                  NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                  return -1;
               }
@@ -1468,9 +1468,9 @@
     int sock, alreadyV6 = 0;
     struct lifreq if2;
 
-     if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+     if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
          if (errno == EPROTONOSUPPORT){
-              if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
+              if ( (sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
                  NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                  return -1;
               }
@@ -1498,7 +1498,7 @@
         strcpy(if2.lifr_name, ifname);
         if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
                 close(sock);
-                if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
+                if ( (sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
                       NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                       return -1;
                 }
@@ -1854,9 +1854,9 @@
     int sock;
     struct ifreq if2;
 
-     if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+     if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
          if (errno == EPROTONOSUPPORT){
-              if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
+              if ( (sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
                  NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
                  return -1;
               }
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -186,6 +186,7 @@
     int fd;
     int len = 0;
     SOCKADDR him;
+    socklen_t slen = sizeof(him);
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -223,7 +224,7 @@
         /* Now that we're a connected socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        if (JVM_GetSockName(fd, (struct sockaddr *)&him, &len) == -1) {
+        if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                             "Error getting socket name");
             return;
@@ -271,7 +272,7 @@
 
     setDefaultScopeID(env, (struct sockaddr *)&rmtaddr);
 
-    if (JVM_Connect(fd, (struct sockaddr *)&rmtaddr, len) == -1) {
+    if (NET_Connect(fd, (struct sockaddr *)&rmtaddr, len) == -1) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
                         "Connect failed");
         return;
@@ -293,7 +294,7 @@
 
 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
     SOCKADDR addr;
-    int len;
+    socklen_t len;
 #endif
 
     if (IS_NULL(fdObj)) {
@@ -315,11 +316,11 @@
             him4->sin_family = AF_UNSPEC;
             len = sizeof(struct sockaddr_in);
         }
-        JVM_Connect(fd, (struct sockaddr *)&addr, len);
+        NET_Connect(fd, (struct sockaddr *)&addr, len);
 
 #ifdef __linux__
         int localPort = 0;
-        if (JVM_GetSockName(fd, (struct sockaddr *)&addr, &len) == -1)
+        if (getsockname(fd, (struct sockaddr *)&addr, &len) == -1)
             return;
 
         localPort = NET_GetPortFromSockaddr((struct sockaddr *)&addr);
@@ -339,7 +340,7 @@
 
 #endif
 #else
-    JVM_Connect(fd, 0, 0);
+    NET_Connect(fd, 0, 0);
 #endif
 }
 
@@ -456,20 +457,11 @@
                      (struct sockaddr *)rmtaddrP, len);
 
     if (ret < 0) {
-        switch (ret) {
-            case JVM_IO_ERR :
-                if (errno == ECONNREFUSED) {
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
+        if (errno == ECONNREFUSED) {
+            JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
                             "ICMP Port Unreachable");
-                } else {
-                    NET_ThrowByNameWithLastError(env, "java/io/IOException", "sendto failed");
-                }
-                break;
-
-            case JVM_IO_INTR:
-                JNU_ThrowByName(env, "java/io/InterruptedIOException",
-                                "operation interrupted");
-                break;
+        } else {
+            NET_ThrowByNameWithLastError(env, "java/io/IOException", "sendto failed");
         }
     }
 
@@ -493,7 +485,7 @@
     jint fd;
     ssize_t n;
     SOCKADDR remote_addr;
-    int len;
+    socklen_t slen = SOCKADDR_LEN;
     char buf[1];
     jint family;
     jobject iaObj;
@@ -514,25 +506,19 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Peek timed out");
             return ret;
-        } else if (ret == JVM_IO_ERR) {
+        } else if (ret == -1) {
             if (errno == EBADF) {
                  JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
                  NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
             }
             return ret;
-        } else if (ret == JVM_IO_INTR) {
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
-            return ret; /* WARNING: SHOULD WE REALLY RETURN -2??? */
         }
     }
 
-    len = SOCKADDR_LEN;
-    n = NET_RecvFrom(fd, buf, 1, MSG_PEEK,
-                     (struct sockaddr *)&remote_addr, &len);
+    n = NET_RecvFrom(fd, buf, 1, MSG_PEEK, (struct sockaddr *)&remote_addr, &slen);
 
-    if (n == JVM_IO_ERR) {
+    if (n == -1) {
 
 #ifdef __solaris__
         if (errno == ECONNREFUSED) {
@@ -552,9 +538,6 @@
             }
         }
         return 0;
-    } else if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", 0);
-        return 0;
     }
 
     iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
@@ -587,7 +570,7 @@
 
     int n;
     SOCKADDR remote_addr;
-    int len;
+    socklen_t slen = SOCKADDR_LEN;
     int port;
 
     if (IS_NULL(fdObj)) {
@@ -616,7 +599,7 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Receive timed out");
             return -1;
-        } else if (ret == JVM_IO_ERR) {
+        } else if (ret == -1) {
 #ifdef __linux__
             if (errno == EBADF) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@@ -627,10 +610,6 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
 #endif
             return -1;
-        } else if (ret == JVM_IO_INTR) {
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
-            return -1;
         }
     }
 
@@ -665,14 +644,13 @@
         fullPacket = &(BUF[0]);
     }
 
-    len = SOCKADDR_LEN;
     n = NET_RecvFrom(fd, fullPacket, packetBufferLen, MSG_PEEK,
-                     (struct sockaddr *)&remote_addr, &len);
+                     (struct sockaddr *)&remote_addr, &slen);
     /* truncate the data if the packet's length is too small */
     if (n > packetBufferLen) {
         n = packetBufferLen;
     }
-    if (n == JVM_IO_ERR) {
+    if (n == -1) {
 
 #ifdef __solaris__
         if (errno == ECONNREFUSED) {
@@ -693,11 +671,6 @@
                  NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
             }
         }
-    } else if (n == JVM_IO_INTR) {
-        (*env)->SetIntField(env, packet, dp_offsetID, 0);
-        (*env)->SetIntField(env, packet, dp_lengthID, 0);
-        JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                        "operation interrupted");
     } else {
         /*
          * success - fill in received address...
@@ -764,7 +737,7 @@
 
     int n;
     SOCKADDR remote_addr;
-    int len;
+    socklen_t slen = SOCKADDR_LEN;
     jboolean retry;
 #ifdef __linux__
     jboolean connected = JNI_FALSE;
@@ -834,7 +807,7 @@
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
-                } else if (ret == JVM_IO_ERR) {
+                } else if (ret == -1) {
 #ifdef __linux__
                     if (errno == EBADF) {
                          JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@@ -844,9 +817,6 @@
 #else
                      JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
 #endif
-                } else if (ret == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "operation interrupted");
                 }
 
                 if (mallocedPacket) {
@@ -857,14 +827,13 @@
             }
         }
 
-        len = SOCKADDR_LEN;
         n = NET_RecvFrom(fd, fullPacket, packetBufferLen, 0,
-                         (struct sockaddr *)&remote_addr, &len);
+                         (struct sockaddr *)&remote_addr, &slen);
         /* truncate the data if the packet's length is too small */
         if (n > packetBufferLen) {
             n = packetBufferLen;
         }
-        if (n == JVM_IO_ERR) {
+        if (n == -1) {
             (*env)->SetIntField(env, packet, dp_offsetID, 0);
             (*env)->SetIntField(env, packet, dp_lengthID, 0);
             if (errno == ECONNREFUSED) {
@@ -877,11 +846,6 @@
                      NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
                  }
             }
-        } else if (n == JVM_IO_INTR) {
-            (*env)->SetIntField(env, packet, dp_offsetID, 0);
-            (*env)->SetIntField(env, packet, dp_lengthID, 0);
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
         } else {
             int port;
             jobject packetAddress;
@@ -950,7 +914,7 @@
         return;
     }
 
-    if ((fd = JVM_Socket(domain, SOCK_DGRAM, 0)) == JVM_IO_ERR) {
+    if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                        "Error creating socket");
         return;
@@ -971,14 +935,14 @@
 
 #ifdef __APPLE__
     arg = 65507;
-    if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_SNDBUF,
-                       (char *)&arg, sizeof(arg)) < 0) {
+    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
+                   (char *)&arg, sizeof(arg)) < 0) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         strerror(errno));
         return;
     }
-    if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_RCVBUF,
-                       (char *)&arg, sizeof(arg)) < 0) {
+    if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
+                   (char *)&arg, sizeof(arg)) < 0) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         strerror(errno));
         return;
@@ -1084,8 +1048,8 @@
         }
     }
 
-    if (JVM_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_IF,
-                       (const char*)&in, sizeof(in)) < 0) {
+    if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+                   (const char*)&in, sizeof(in)) < 0) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                        "Error setting socket option");
     }
@@ -1108,8 +1072,8 @@
     }
     index = (*env)->GetIntField(env, value, ni_indexID);
 
-    if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
-                       (const char*)&index, sizeof(index)) < 0) {
+    if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                   (const char*)&index, sizeof(index)) < 0) {
         if (errno == EINVAL && index > 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                 "IPV6_MULTICAST_IF failed (interface has IPv4 "
@@ -1133,8 +1097,8 @@
 
     in.s_addr = htonl( getInetAddress_addr(env, value) );
 
-    if (JVM_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_IF,
-                       (const char*)&in, sizeof(in)) < 0) {
+    if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+                   (const char*)&in, sizeof(in)) < 0) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                          "Error setting socket option");
     }
@@ -1482,10 +1446,10 @@
 
         struct in_addr in;
         struct in_addr *inP = &in;
-        int len = sizeof(struct in_addr);
+        socklen_t len = sizeof(struct in_addr);
 
-        if (JVM_GetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_IF,
-                           (char *)inP, &len) < 0) {
+        if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+                       (char *)inP, &len) < 0) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                              "Error getting socket option");
             return NULL;
@@ -1568,14 +1532,14 @@
         static jmethodID ia_anyLocalAddressID;
 
         int index;
-        int len = sizeof(index);
+        socklen_t len = sizeof(index);
 
         jobjectArray addrArray;
         jobject addr;
         jobject ni;
 
-        if (JVM_GetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
-                           (char*)&index, &len) < 0) {
+        if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                       (char*)&index, &len) < 0) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                            "Error getting socket option");
             return NULL;
@@ -1789,8 +1753,8 @@
  */
 static void setTTL(JNIEnv *env, int fd, jint ttl) {
     char ittl = (char)ttl;
-    if (JVM_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
-                       sizeof(ittl)) < 0) {
+    if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
+                   sizeof(ittl)) < 0) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                        "Error setting socket option");
     }
@@ -1802,8 +1766,8 @@
 #ifdef AF_INET6
 static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
     int ittl = (int)ttl;
-    if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
-                       (char*)&ittl, sizeof(ittl)) < 0) {
+    if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+                   (char*)&ittl, sizeof(ittl)) < 0) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                        "Error setting socket option");
     }
@@ -1883,22 +1847,22 @@
 #ifdef AF_INET6
     if (ipv6_available()) {
         int ttl = 0;
-        int len = sizeof(ttl);
+        socklen_t len = sizeof(ttl);
 
-        if (JVM_GetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
-                               (char*)&ttl, &len) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error getting socket option");
-                return -1;
-            }
+        if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+                       (char*)&ttl, &len) < 0) {
+            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                         "Error getting socket option");
+            return -1;
+        }
         return (jint)ttl;
     } else
 #endif /* AF_INET6 */
         {
             u_char ttl = 0;
-            int len = sizeof(ttl);
-            if (JVM_GetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
-                               (char*)&ttl, &len) < 0) {
+            socklen_t len = sizeof(ttl);
+            if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
+                           (char*)&ttl, &len) < 0) {
                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                "Error getting socket option");
                 return -1;
@@ -2050,10 +2014,10 @@
             if (ipv6_available()) {
 
                 int index;
-                int len = sizeof(index);
+                socklen_t len = sizeof(index);
 
-                if (JVM_GetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
-                                   (char*)&index, &len) < 0) {
+                if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                               (char*)&index, &len) < 0) {
                     NET_ThrowCurrent(env, "getsockopt IPV6_MULTICAST_IF failed");
                     return;
                 }
@@ -2089,8 +2053,8 @@
         /*
          * Join the multicast group.
          */
-        if (JVM_SetSockOpt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
-                           (char *) &mname, mname_len) < 0) {
+        if (setsockopt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
+                       (char *) &mname, mname_len) < 0) {
 
             /*
              * If IP_ADD_MEMBERSHIP returns ENOPROTOOPT on Linux and we've got
@@ -2165,12 +2129,12 @@
         memcpy((void *)&(mname6.ipv6mr_multiaddr), caddr, sizeof(struct in6_addr));
         if (IS_NULL(niObj)) {
             int index;
-            int len = sizeof(index);
+            socklen_t len = sizeof(index);
 
-            if (JVM_GetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
-                             (char*)&index, &len) < 0) {
+            if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                           (char*)&index, &len) < 0) {
                 NET_ThrowCurrent(env, "getsockopt IPV6_MULTICAST_IF failed");
-               return;
+                return;
             }
 
 #ifdef __linux__
@@ -2211,8 +2175,8 @@
 #endif
 
         /* Join the multicast group */
-        if (JVM_SetSockOpt(fd, IPPROTO_IPV6, (join ? ADD_MEMBERSHIP : DRP_MEMBERSHIP),
-                           (char *) &mname6, sizeof (mname6)) < 0) {
+        if (setsockopt(fd, IPPROTO_IPV6, (join ? ADD_MEMBERSHIP : DRP_MEMBERSHIP),
+                       (char *) &mname6, sizeof (mname6)) < 0) {
 
             if (join) {
                 NET_ThrowCurrent(env, "setsockopt " S_ADD_MEMBERSHIP " failed");
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -111,8 +111,8 @@
      * Finally shutdown sv[0] (any reads to this fd will get
      * EOF; any writes will get an error).
      */
-    JVM_SocketShutdown(sv[0], 2);
-    JVM_SocketClose(sv[1]);
+    shutdown(sv[0], 2);
+    close(sv[1]);
 
     return sv[0];
 }
@@ -205,7 +205,7 @@
         return;
     }
 
-    if ((fd = JVM_Socket(domain, type, 0)) == JVM_IO_ERR) {
+    if ((fd = socket(domain, type, 0)) == -1) {
         /* note: if you run out of fds, you may not be able to load
          * the exception class, and get a NoClassDefFoundError
          * instead.
@@ -235,8 +235,8 @@
     if (ssObj != NULL) {
         int arg = 1;
         SET_NONBLOCKING(fd);
-        if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
-                           sizeof(arg)) < 0) {
+        if (NET_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
+                       sizeof(arg)) < 0) {
             NET_ThrowNew(env, errno, "cannot set SO_REUSEADDR");
             close(fd);
             return;
@@ -303,7 +303,7 @@
     if (timeout <= 0) {
         connect_rv = NET_Connect(fd, (struct sockaddr *)&him, len);
 #ifdef __solaris__
-        if (connect_rv == JVM_IO_ERR && errno == EINPROGRESS ) {
+        if (connect_rv == -1 && errno == EINPROGRESS ) {
 
             /* This can happen if a blocking connect is interrupted by a signal.
              * See 6343810.
@@ -330,7 +330,7 @@
                 }
 #endif
 
-                if (connect_rv == JVM_IO_ERR) {
+                if (connect_rv == -1) {
                     if (errno == EINTR) {
                         continue;
                     } else {
@@ -338,18 +338,18 @@
                     }
                 }
                 if (connect_rv > 0) {
-                    int optlen;
+                    socklen_t optlen;
                     /* has connection been established */
                     optlen = sizeof(connect_rv);
-                    if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR,
-                                        (void*)&connect_rv, &optlen) <0) {
+                    if (getsockopt(fd, SOL_SOCKET, SO_ERROR,
+                                   (void*)&connect_rv, &optlen) <0) {
                         connect_rv = errno;
                     }
 
                     if (connect_rv != 0) {
                         /* restore errno */
                         errno = connect_rv;
-                        connect_rv = JVM_IO_ERR;
+                        connect_rv = -1;
                     }
                     break;
                 }
@@ -369,7 +369,7 @@
 
         /* connection not established immediately */
         if (connect_rv != 0) {
-            int optlen;
+            socklen_t optlen;
             jlong prevTime = JVM_CurrentTimeMillis(env, 0);
 
             if (errno != EINPROGRESS) {
@@ -446,14 +446,14 @@
                  * shutdown input & output.
                  */
                 SET_BLOCKING(fd);
-                JVM_SocketShutdown(fd, 2);
+                shutdown(fd, 2);
                 return;
             }
 
             /* has connection been established */
             optlen = sizeof(connect_rv);
-            if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                               &optlen) <0) {
+            if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                           &optlen) <0) {
                 connect_rv = errno;
             }
         }
@@ -464,7 +464,7 @@
         /* restore errno */
         if (connect_rv != 0) {
             errno = connect_rv;
-            connect_rv = JVM_IO_ERR;
+            connect_rv = -1;
         }
     }
 
@@ -482,21 +482,20 @@
          * instead of EADDRNOTAVAIL. We handle this here so that
          * a more descriptive exception text is used.
          */
-        if (connect_rv == JVM_IO_ERR && errno == EINVAL) {
+        if (connect_rv == -1 && errno == EINVAL) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                 "Invalid argument or cannot assign requested address");
             return;
         }
 #endif
-        if (connect_rv == JVM_IO_INTR) {
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
 #if defined(EPROTO)
-        } else if (errno == EPROTO) {
+        if (errno == EPROTO) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ProtocolException",
                            "Protocol error");
+            return;
+        }
 #endif
-        } else if (errno == ECONNREFUSED) {
+        if (errno == ECONNREFUSED) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
                            "Connection refused");
         } else if (errno == ETIMEDOUT) {
@@ -532,8 +531,8 @@
         /* Now that we're a connected socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        len = SOCKADDR_LEN;
-        if (JVM_GetSockName(fd, (struct sockaddr *)&him, &len) == -1) {
+        socklen_t slen = SOCKADDR_LEN;
+        if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                            "Error getting socket name");
         } else {
@@ -594,10 +593,11 @@
 
     /* initialize the local port */
     if (localport == 0) {
+        socklen_t slen = sizeof(him);
         /* Now that we're a connected socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        if (JVM_GetSockName(fd, (struct sockaddr *)&him, &len) == -1) {
+        if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                            "Error getting socket name");
             return;
@@ -638,7 +638,7 @@
     if (count == 0x7fffffff)
         count -= 1;
 
-    if (JVM_Listen(fd, count) == JVM_IO_ERR) {
+    if (listen(fd, count) == -1) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                        "Listen failed");
     }
@@ -671,9 +671,7 @@
     jint newfd;
 
     SOCKADDR him;
-    int len;
-
-    len = SOCKADDR_LEN;
+    socklen_t slen = SOCKADDR_LEN;
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -716,20 +714,16 @@
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Accept timed out");
             return;
-        } else if (ret == JVM_IO_ERR) {
+        } else if (ret == -1) {
             if (errno == EBADF) {
                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
             }
             return;
-        } else if (ret == JVM_IO_INTR) {
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
-            return;
         }
 
-        newfd = NET_Accept(fd, (struct sockaddr *)&him, (jint*)&len);
+        newfd = NET_Accept(fd, (struct sockaddr *)&him, &slen);
 
         /* connection accepted */
         if (newfd >= 0) {
@@ -816,8 +810,8 @@
     } else {
         fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
     }
-    /* JVM_SocketAvailable returns 0 for failure, 1 for success */
-    if (!JVM_SocketAvailable(fd, &ret)){
+    /* NET_SocketAvailable returns 0 for failure, 1 for success */
+    if (NET_SocketAvailable(fd, &ret) == 0){
         if (errno == ECONNRESET) {
             JNU_ThrowByName(env, "sun/net/ConnectionResetException", "");
         } else {
@@ -881,7 +875,7 @@
     } else {
         fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
     }
-    JVM_SocketShutdown(fd, howto);
+    shutdown(fd, howto);
 }
 
 
@@ -1101,13 +1095,8 @@
         }
 
     }
-    n = JVM_Send(fd, (char *)&d, 1, MSG_OOB);
-    if (n == JVM_IO_ERR) {
+    n = NET_Send(fd, (char *)&d, 1, MSG_OOB);
+    if (n == -1) {
         NET_ThrowByNameWithLastError(env, "java/io/IOException", "Write failed");
-        return;
-    }
-    if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", 0);
-        return;
     }
 }
--- a/jdk/src/solaris/native/java/net/SocketInputStream.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/SocketInputStream.c	Tue Feb 25 12:35:14 2014 +0000
@@ -105,16 +105,13 @@
             if (nread == 0) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Read timed out");
-            } else if (nread == JVM_IO_ERR) {
+            } else if (nread == -1) {
                 if (errno == EBADF) {
                      JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
                  } else {
                      NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                                   "select/poll failed");
                  }
-            } else if (nread == JVM_IO_INTR) {
-                JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "Operation interrupted");
             }
             if (bufP != BUF) {
                 free(bufP);
--- a/jdk/src/solaris/native/java/net/SocketOutputStream.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/SocketOutputStream.c	Tue Feb 25 12:35:14 2014 +0000
@@ -110,16 +110,12 @@
                 loff += n;
                 continue;
             }
-            if (n == JVM_IO_INTR) {
-                JNU_ThrowByName(env, "java/io/InterruptedIOException", 0);
+            if (errno == ECONNRESET) {
+                JNU_ThrowByName(env, "sun/net/ConnectionResetException",
+                    "Connection reset");
             } else {
-                if (errno == ECONNRESET) {
-                    JNU_ThrowByName(env, "sun/net/ConnectionResetException",
-                        "Connection reset");
-                } else {
-                    NET_ThrowByNameWithLastError(env, "java/net/SocketException",
-                        "Write failed");
-                }
+                NET_ThrowByNameWithLastError(env, "java/net/SocketException",
+                    "Write failed");
             }
             if (bufP != BUF) {
                 free(bufP);
--- a/jdk/src/solaris/native/java/net/bsd_close.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/bsd_close.c	Tue Feb 25 12:35:14 2014 +0000
@@ -297,9 +297,8 @@
 }
 
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
-       struct sockaddr *from, int *fromlen) {
-    /* casting int *fromlen -> socklen_t* Both are ints */
-    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, (socklen_t *)fromlen) );
+       struct sockaddr *from, socklen_t *fromlen) {
+    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
 }
 
 int NET_Send(int s, void *msg, int len, unsigned int flags) {
@@ -315,12 +314,8 @@
     BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
 }
 
-int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
-    socklen_t len = *addrlen;
-    int error = accept(s, addr, &len);
-    if (error != -1)
-        *addrlen = (int)len;
-    BLOCKING_IO_RETURN_INT( s, error );
+int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
+    BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
 }
 
 int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
--- a/jdk/src/solaris/native/java/net/linux_close.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/linux_close.c	Tue Feb 25 12:35:14 2014 +0000
@@ -279,10 +279,8 @@
 }
 
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
-       struct sockaddr *from, int *fromlen) {
-    socklen_t socklen = *fromlen;
-    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
-    *fromlen = socklen;
+       struct sockaddr *from, socklen_t *fromlen) {
+    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
 }
 
 int NET_Send(int s, void *msg, int len, unsigned int flags) {
@@ -298,10 +296,8 @@
     BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
 }
 
-int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
-    socklen_t socklen = *addrlen;
-    BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
-    *addrlen = socklen;
+int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
+    BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
 }
 
 int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
--- a/jdk/src/solaris/native/java/net/net_util_md.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/net_util_md.c	Tue Feb 25 12:35:14 2014 +0000
@@ -40,18 +40,21 @@
 #include <limits.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#include <sys/ioctl.h>
 #ifndef MAXINT
 #define MAXINT INT_MAX
 #endif
 #endif
 
 #ifdef __solaris__
+#include <sys/filio.h>
 #include <sys/sockio.h>
 #include <stropts.h>
 #include <inet/nd.h>
 #endif
 
 #ifdef __linux__
+#include <sys/ioctl.h>
 #include <arpa/inet.h>
 #include <net/route.h>
 #include <sys/utsname.h>
@@ -110,6 +113,7 @@
 }
 
 int getDefaultScopeID(JNIEnv *env) {
+    int defaultIndex = 0;
     static jclass ni_class = NULL;
     static jfieldID ni_defaultIndexID;
     if (ni_class == NULL) {
@@ -121,12 +125,25 @@
                                                      "defaultIndex", "I");
         ni_class = c;
     }
-    int defaultIndex = 0;
     defaultIndex = (*env)->GetStaticIntField(env, ni_class,
                                              ni_defaultIndexID);
     return defaultIndex;
 }
 
+#define RESTARTABLE(_cmd, _result) do { \
+    do { \
+        _result = _cmd; \
+    } while((_result == -1) && (errno == EINTR)); \
+} while(0)
+
+int NET_SocketAvailable(int s, jint *pbytes) {
+    int result;
+    RESTARTABLE(ioctl(s, FIONREAD, pbytes), result);
+    // note: ioctl can return 0 when successful, NET_SocketAvailable
+    // is expected to return 0 on failure and 1 on success.
+    return (result == -1) ? 0 : 1;
+}
+
 #ifdef __solaris__
 static int init_tcp_max_buf, init_udp_max_buf;
 static int tcp_max_buf;
@@ -322,7 +339,7 @@
     SOCKADDR sa;
     socklen_t sa_len = sizeof(sa);
 
-    fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0) ;
+    fd = socket(AF_INET6, SOCK_STREAM, 0) ;
     if (fd < 0) {
         /*
          *  TODO: We really cant tell since it may be an unrelated error
@@ -1207,6 +1224,7 @@
                int *len)
 {
     int rv;
+    socklen_t socklen = *len;
 
 #ifdef AF_INET6
     if ((level == IPPROTO_IP) && (opt == IP_TOS)) {
@@ -1223,15 +1241,8 @@
     }
 #endif
 
-#ifdef __solaris__
-    rv = getsockopt(fd, level, opt, result, len);
-#else
-    {
-        socklen_t socklen = *len;
-        rv = getsockopt(fd, level, opt, result, &socklen);
-        *len = socklen;
-    }
-#endif
+    rv = getsockopt(fd, level, opt, result, &socklen);
+    *len = socklen;
 
     if (rv < 0) {
         return rv;
@@ -1342,7 +1353,8 @@
 #ifdef __solaris__
     if (level == SOL_SOCKET) {
         if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
-            int sotype=0, arglen;
+            int sotype=0;
+            socklen_t arglen;
             int *bufsize, maxbuf;
             int ret;
 
@@ -1546,7 +1558,8 @@
      * corresponding IPv4 port is in use.
      */
     if (ipv6_available()) {
-        int arg, len;
+        int arg;
+        socklen_t len;
 
         len = sizeof(arg);
         if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
--- a/jdk/src/solaris/native/java/net/net_util_md.h	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/solaris/native/java/net/net_util_md.h	Tue Feb 25 12:35:14 2014 +0000
@@ -36,56 +36,24 @@
 #include <sys/poll.h>
 #endif
 
-
-/*
-   AIX needs a workaround for I/O cancellation, see:
-   http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm
-   ...
-   The close subroutine is blocked until all subroutines which use the file
-   descriptor return to usr space. For example, when a thread is calling close
-   and another thread is calling select with the same file descriptor, the
-   close subroutine does not return until the select call returns.
-   ...
-*/
-#if defined(__linux__) || defined(MACOSX) || defined (_AIX)
-extern int NET_Timeout(int s, long timeout);
-extern int NET_Read(int s, void* buf, size_t len);
-extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
-       struct sockaddr *from, int *fromlen);
-extern int NET_ReadV(int s, const struct iovec * vector, int count);
-extern int NET_Send(int s, void *msg, int len, unsigned int flags);
-extern int NET_SendTo(int s, const void *msg, int len,  unsigned  int
+int NET_Timeout(int s, long timeout);
+int NET_Read(int s, void* buf, size_t len);
+int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
+                 struct sockaddr *from, socklen_t *fromlen);
+int NET_ReadV(int s, const struct iovec * vector, int count);
+int NET_Send(int s, void *msg, int len, unsigned int flags);
+int NET_SendTo(int s, const void *msg, int len,  unsigned  int
        flags, const struct sockaddr *to, int tolen);
-extern int NET_Writev(int s, const struct iovec * vector, int count);
-extern int NET_Connect(int s, struct sockaddr *addr, int addrlen);
-extern int NET_Accept(int s, struct sockaddr *addr, int *addrlen);
-extern int NET_SocketClose(int s);
-extern int NET_Dup2(int oldfd, int newfd);
-
-#ifdef USE_SELECT
+int NET_Writev(int s, const struct iovec * vector, int count);
+int NET_Connect(int s, struct sockaddr *addr, int addrlen);
+int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+int NET_SocketClose(int s);
+int NET_Dup2(int oldfd, int newfd);
 extern int NET_Select(int s, fd_set *readfds, fd_set *writefds,
                fd_set *exceptfds, struct timeval *timeout);
-#else
 extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
-#endif
-
-#else
 
-#define NET_Timeout     JVM_Timeout
-#define NET_Read        JVM_Read
-#define NET_RecvFrom    JVM_RecvFrom
-#define NET_ReadV       readv
-#define NET_Send        JVM_Send
-#define NET_SendTo      JVM_SendTo
-#define NET_WriteV      writev
-#define NET_Connect     JVM_Connect
-#define NET_Accept      JVM_Accept
-#define NET_SocketClose JVM_SocketClose
-#define NET_Dup2        dup2
-#define NET_Select      select
-#define NET_Poll        poll
-
-#endif
+int NET_SocketAvailable(int s, jint *pbytes);
 
 #if defined(__linux__) && defined(AF_INET6)
 int getDefaultIPv6Interface(struct in6_addr *target_addr);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/java/net/solaris_close.c	Tue Feb 25 12:35:14 2014 +0000
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <errno.h>
+#include <sys/socket.h>
+#include <stropts.h>
+#include <unistd.h>
+
+/* Support for restartable system calls on Solaris. */
+
+#define RESTARTABLE_RETURN_INT(_cmd) do {             \
+    int _result;                                      \
+    if (1) {                                          \
+        do {                                          \
+            _result = _cmd;                           \
+        } while((_result == -1) && (errno == EINTR)); \
+        return _result;                               \
+    }                                                 \
+} while(0)
+
+int NET_Read(int s, void* buf, size_t len) {
+    RESTARTABLE_RETURN_INT(recv(s, buf, len, 0));
+}
+
+int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
+                 struct sockaddr *from, socklen_t *fromlen) {
+    RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen));
+}
+
+int NET_ReadV(int s, const struct iovec * vector, int count) {
+    RESTARTABLE_RETURN_INT(readv(s, vector, count));
+}
+
+int NET_WriteV(int s, const struct iovec * vector, int count) {
+    RESTARTABLE_RETURN_INT(writev(s, vector, count));
+}
+
+int NET_Send(int s, void *msg, int len, unsigned int flags) {
+    RESTARTABLE_RETURN_INT(send(s, msg, len, flags));
+}
+
+int NET_SendTo(int s, const void *msg, int len,  unsigned  int flags,
+               const struct sockaddr *to, int tolen) {
+    RESTARTABLE_RETURN_INT(sendto(s, msg, len, flags, to, tolen));
+}
+
+int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
+    RESTARTABLE_RETURN_INT(connect(s, addr, addrlen));
+}
+
+int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
+    RESTARTABLE_RETURN_INT(accept(s, addr, addrlen));
+}
+
+int NET_SocketClose(int fd) {
+    return close(fd);
+}
+
+int NET_Dup2(int fd, int fd2) {
+    return dup2(fd, fd2);
+}
+
+int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
+    RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
+}
+
+int NET_Select(int s, fd_set *readfds, fd_set *writefds,
+               fd_set *exceptfds, struct timeval *timeout) {
+    RESTARTABLE_RETURN_INT(select(s, readfds, writefds, exceptfds, timeout));
+}
+
+int NET_Timeout(int s, long timeout) {
+    int result;
+    struct timeval t;
+    long prevtime, newtime;
+    struct pollfd pfd;
+    pfd.fd = s;
+    pfd.events = POLLIN;
+
+    if (timeout > 0) {
+        gettimeofday(&t, NULL);
+        prevtime = (t.tv_sec * 1000)  +  t.tv_usec / 1000;
+    }
+
+    for(;;) {
+        result = poll(&pfd, 1, timeout);
+        if (result < 0 && errno == EINTR) {
+            if (timeout > 0) {
+                gettimeofday(&t, NULL);
+                newtime = (t.tv_sec * 1000)  +  t.tv_usec /1000;
+                timeout -= newtime - prevtime;
+                if (timeout <= 0)
+                    return 0;
+                prevtime = newtime;
+            }
+        } else {
+            return result;
+        }
+    }
+}
--- a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -55,7 +55,7 @@
             break;
         }
         if (recvfrom(fd, buf, 1, MSG_PEEK,
-                         (struct sockaddr *)&rmtaddr, &addrlen) != JVM_IO_ERR) {
+                         (struct sockaddr *)&rmtaddr, &addrlen) != SOCKET_ERROR) {
             break;
         }
         if (WSAGetLastError() != WSAECONNRESET) {
@@ -201,7 +201,7 @@
     int len = sizeof(sa);
 
     if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) {
-        NET_ThrowNew(env, WSAGetLastError(), "JVM_GetSockName");
+        NET_ThrowNew(env, WSAGetLastError(), "getsockname");
         return -1;
     }
     return (int) ntohs((u_short)GET_PORT(&sa));
@@ -284,12 +284,9 @@
                 if (rv == 0) {
                     JNU_ThrowByName(env,JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
-                } else if (rv == JVM_IO_ERR) {
+                } else if (rv == -1) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                     "Socket closed");
-                } else if (rv == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "operation interrupted");
                 }
                 if (packetBufferLen > MAX_BUFFER_LEN) {
                     free(fullPacket);
@@ -409,7 +406,7 @@
     int rv;
 
     if (connected) {
-        sap = 0; /* arg to JVM_Sendto () null in this case */
+        sap = 0; /* arg to sendto () null in this case */
         sa_len = 0;
     } else {
         if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
@@ -438,11 +435,8 @@
                                (jbyte *)fullPacket);
     rv = sendto(fd, fullPacket, length, 0, (struct sockaddr *)sap, sa_len);
     if (rv == SOCKET_ERROR) {
-        if (rv == JVM_IO_ERR) {
+        if (rv == -1) {
             NET_ThrowNew(env, WSAGetLastError(), "Datagram send failed");
-        } else if (rv == JVM_IO_INTR) {
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
         }
     }
 
--- a/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -98,7 +98,7 @@
     rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind);
 
     if (rv == SOCKET_ERROR)
-        NET_ThrowNew(env, WSAGetLastError(), "JVM_Bind");
+        NET_ThrowNew(env, WSAGetLastError(), "NET_Bind");
 }
 
 /*
@@ -451,10 +451,8 @@
     unsigned char d = (unsigned char) data & 0xff;
 
     n = send(fd, (char *)&data, 1, MSG_OOB);
-    if (n == JVM_IO_ERR) {
+    if (n == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "send");
-    } else if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", 0);
     }
 }
 
--- a/jdk/src/windows/native/java/net/Inet4AddressImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/Inet4AddressImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -477,7 +477,7 @@
      * Can't create a raw socket, so let's try a TCP socket
      */
     fd = NET_Socket(AF_INET, SOCK_STREAM, 0);
-    if (fd == JVM_IO_ERR) {
+    if (fd == SOCKET_ERROR) {
         /* note: if you run out of fds, you may not be able to load
          * the exception class, and get a NoClassDefFoundError
          * instead.
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -563,7 +563,7 @@
 
     /* No good, let's fall back on TCP */
     fd = NET_Socket(AF_INET6, SOCK_STREAM, 0);
-    if (fd == JVM_IO_ERR) {
+    if (fd == SOCKET_ERROR) {
         /* note: if you run out of fds, you may not be able to load
          * the exception class, and get a NoClassDefFoundError
          * instead.
--- a/jdk/src/windows/native/java/net/SocketInputStream.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/SocketInputStream.c	Tue Feb 25 12:35:14 2014 +0000
@@ -105,11 +105,8 @@
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                     "Read timed out");
-                } else if (ret == JVM_IO_ERR) {
+                } else if (ret == -1) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
-                } else if (ret == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "Operation interrupted");
                 }
                 if (bufP != BUF) {
                     free(bufP);
--- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -353,7 +353,7 @@
             break;
         }
         if (recvfrom(fd, buf, 1, MSG_PEEK,
-                         (struct sockaddr *)&rmtaddr, &addrlen) != JVM_IO_ERR) {
+                         (struct sockaddr *)&rmtaddr, &addrlen) != SOCKET_ERROR) {
             break;
         }
         if (WSAGetLastError() != WSAECONNRESET) {
@@ -508,7 +508,7 @@
             fd = fd1;
         }
         if (getsockname(fd, (struct sockaddr *)&lcladdr, &lcladdrlen) == -1) {
-            NET_ThrowCurrent(env, "JVM_GetSockName");
+            NET_ThrowCurrent(env, "getsockname");
             return;
         }
         port = ntohs((u_short) GET_PORT (&lcladdr));
@@ -700,7 +700,7 @@
     }
 
     if (connected) {
-        addrp = 0; /* arg to JVM_Sendto () null in this case */
+        addrp = 0; /* arg to sendto () null in this case */
         addrlen = 0;
     } else {
       if (NET_InetAddressToSockaddr(env, iaObj, packetPort, (struct sockaddr *)&rmtaddr, &addrlen, JNI_FALSE) != 0) {
@@ -757,15 +757,9 @@
 
     (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen,
                                (jbyte *)fullPacket);
-    switch (sendto(fd, fullPacket, packetBufferLen, 0,
-                       (struct sockaddr *)addrp, addrlen)) {
-        case JVM_IO_ERR:
-            NET_ThrowCurrent(env, "Datagram send failed");
-            break;
-
-        case JVM_IO_INTR:
-            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                            "operation interrupted");
+    if (sendto(fd, fullPacket, packetBufferLen, 0,
+               (struct sockaddr *)addrp, addrlen) == SOCKET_ERROR) {
+         NET_ThrowCurrent(env, "Datagram send failed");
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
@@ -851,13 +845,9 @@
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                 "Peek timed out");
                 return ret;
-            } else if (ret == JVM_IO_ERR) {
+            } else if (ret == -1) {
                 NET_ThrowCurrent(env, "timeout in datagram socket peek");
                 return ret;
-            } else if (ret == JVM_IO_INTR) {
-                JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                "operation interrupted");
-                return ret;
             }
         }
 
@@ -865,7 +855,7 @@
         n = recvfrom(fd, buf, 1, MSG_PEEK,
                          (struct sockaddr *)&remote_addr, &remote_addrsize);
 
-        if (n == JVM_IO_ERR) {
+        if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
                 jboolean connected;
 
@@ -905,14 +895,10 @@
         }
     } while (retry);
 
-    if (n == JVM_IO_ERR && WSAGetLastError() != WSAEMSGSIZE) {
+    if (n == SOCKET_ERROR && WSAGetLastError() != WSAEMSGSIZE) {
         NET_ThrowCurrent(env, "Datagram peek failed");
         return 0;
     }
-    if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", 0);
-        return 0;
-    }
     setInetAddress_addr(env, addressObj, ntohl(remote_addr.sin_addr.s_addr));
     setInetAddress_family(env, addressObj, IPv4);
 
@@ -1035,11 +1021,8 @@
                 if (ret == 0) {
                     JNU_ThrowByName(env,JNU_JAVANETPKG "SocketTimeoutException",
                                         "Peek timed out");
-                } else if (ret == JVM_IO_ERR) {
+                } else if (ret == -1) {
                     NET_ThrowCurrent(env, "timeout in datagram socket peek");
-                } else if (ret == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "operation interrupted");
                 }
                 if (packetBufferLen > MAX_BUFFER_LEN) {
                     free(fullPacket);
@@ -1059,12 +1042,9 @@
                 if (ret == 0) {
                     JNU_ThrowByName(env,JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
-                } else if (ret == JVM_IO_ERR) {
+                } else if (ret == -1) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                     "Socket closed");
-                } else if (ret == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "operation interrupted");
                 }
                 if (packetBufferLen > MAX_BUFFER_LEN) {
                     free(fullPacket);
@@ -1077,7 +1057,7 @@
         n = recvfrom(fduse, fullPacket, packetBufferLen, MSG_PEEK,
                          (struct sockaddr *)&remote_addr, &remote_addrsize);
         port = (int) ntohs ((u_short) GET_PORT((SOCKETADDRESS *)&remote_addr));
-        if (n == JVM_IO_ERR) {
+        if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
                 jboolean connected;
 
@@ -1244,12 +1224,9 @@
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
-                } else if (ret == JVM_IO_ERR) {
+                } else if (ret == -1) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                     "Socket closed");
-                } else if (ret == JVM_IO_INTR) {
-                    JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                    "operation interrupted");
                 }
                 return;
             }
@@ -1324,12 +1301,9 @@
             if (ret == 0) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                 "Receive timed out");
-            } else if (ret == JVM_IO_ERR) {
+            } else if (ret == -1) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                 "Socket closed");
-            } else if (ret == JVM_IO_INTR) {
-                JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                "operation interrupted");
             }
             if (packetBufferLen > MAX_BUFFER_LEN) {
                 free(fullPacket);
@@ -1348,7 +1322,7 @@
         n = recvfrom(fduse, fullPacket, packetBufferLen, 0,
                          (struct sockaddr *)&remote_addr, &remote_addrsize);
 
-        if (n == JVM_IO_ERR) {
+        if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
                 /*
                  * An icmp port unreachable has been received - consume any other
@@ -1392,12 +1366,9 @@
                         if (ret == 0) {
                             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                             "Receive timed out");
-                        } else if (ret == JVM_IO_ERR) {
+                        } else if (ret == -1) {
                             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                             "Socket closed");
-                        } else if (ret == JVM_IO_INTR) {
-                            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
-                                            "operation interrupted");
                         }
                         if (packetBufferLen > MAX_BUFFER_LEN) {
                             free(fullPacket);
@@ -1500,7 +1471,7 @@
     } else {
         fd =  (int) socket (AF_INET, SOCK_DGRAM, 0);
     }
-    if (fd == JVM_IO_ERR) {
+    if (fd == SOCKET_ERROR) {
         NET_ThrowCurrent(env, "Socket creation failed");
         return;
     }
@@ -1518,7 +1489,7 @@
         WSAIoctl(fd,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
         t = TRUE;
         fd1 = socket (AF_INET6, SOCK_DGRAM, 0);
-        if (fd1 == JVM_IO_ERR) {
+        if (fd1 == SOCKET_ERROR) {
             NET_ThrowCurrent(env, "Socket creation failed");
             return;
         }
--- a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c	Tue Feb 25 12:35:14 2014 +0000
@@ -37,7 +37,6 @@
 #include "java_io_FileDescriptor.h"
 #include "java_lang_Integer.h"
 
-#include "jvm.h"
 #include "net_util.h"
 #include "jni_util.h"
 
@@ -473,7 +472,7 @@
     }
 
     if (rv == -1) {
-        NET_ThrowCurrent(env, "JVM_Bind");
+        NET_ThrowCurrent(env, "NET_Bind");
         return;
     }
 
@@ -1162,12 +1161,8 @@
 
     }
     n = send(fd, (char *)&data, 1, MSG_OOB);
-    if (n == JVM_IO_ERR) {
+    if (n == -1) {
         NET_ThrowCurrent(env, "send");
         return;
     }
-    if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", 0);
-        return;
-    }
 }
--- a/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c	Mon Feb 24 11:24:43 2014 -0800
+++ b/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c	Tue Feb 25 12:35:14 2014 +0000
@@ -45,9 +45,6 @@
 static jfieldID ptype_httpID;
 static jfieldID ptype_socksID;
 
-#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); }
-
-
 /*
  * Class:     sun_net_spi_DefaultProxySelector
  * Method:    init
@@ -62,17 +59,30 @@
   /**
    * Get all the method & field IDs for later use.
    */
-  CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy"));
+  cls = (*env)->FindClass(env,"java/net/Proxy");
+  CHECK_NULL_RETURN(cls, JNI_FALSE);
   proxy_class = (*env)->NewGlobalRef(env, cls);
-  CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy$Type"));
+  CHECK_NULL_RETURN(proxy_class, JNI_FALSE);
+  cls = (*env)->FindClass(env,"java/net/Proxy$Type");
+  CHECK_NULL_RETURN(cls, JNI_FALSE);
   ptype_class = (*env)->NewGlobalRef(env, cls);
-  CHECK_NULL(cls = (*env)->FindClass(env, "java/net/InetSocketAddress"));
+  CHECK_NULL_RETURN(ptype_class, JNI_FALSE);
+  cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
+  CHECK_NULL_RETURN(cls, JNI_FALSE);
   isaddr_class = (*env)->NewGlobalRef(env, cls);
-  proxy_ctrID = (*env)->GetMethodID(env, proxy_class, "<init>", "(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V");
+  CHECK_NULL_RETURN(isaddr_class, JNI_FALSE);
+  proxy_ctrID = (*env)->GetMethodID(env, proxy_class, "<init>",
+                                    "(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V");
+  CHECK_NULL_RETURN(proxy_ctrID, JNI_FALSE);
   pr_no_proxyID = (*env)->GetStaticFieldID(env, proxy_class, "NO_PROXY", "Ljava/net/Proxy;");
+  CHECK_NULL_RETURN(pr_no_proxyID, JNI_FALSE);
   ptype_httpID = (*env)->GetStaticFieldID(env, ptype_class, "HTTP", "Ljava/net/Proxy$Type;");
+  CHECK_NULL_RETURN(ptype_httpID, JNI_FALSE);
   ptype_socksID = (*env)->GetStaticFieldID(env, ptype_class, "SOCKS", "Ljava/net/Proxy$Type;");
-  isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved", "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;");
+  CHECK_NULL_RETURN(ptype_socksID, JNI_FALSE);
+  isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved",
+                                                        "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;");
+  CHECK_NULL_RETURN(isaddr_createUnresolvedID, JNI_FALSE);
 
   /**
    * Let's see if we can find the proper Registry entry.