jdk/src/solaris/native/java/net/NetworkInterface.c
changeset 6108 d5bfa0bc6123
parent 6002 4df5b9bcf842
child 6129 e76ab178e431
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Mon Jul 12 15:52:06 2010 -0700
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Tue Jul 13 15:32:36 2010 +0400
@@ -753,19 +753,27 @@
      * If IPv6 is available then enumerate IPv6 addresses.
      */
 #ifdef AF_INET6
-        sock =  openSocket(env, AF_INET6);
-        if (sock < 0 && (*env)->ExceptionOccurred(env)) {
-            freeif(ifs);
-            return NULL;
-        }
+
+        /* User can disable ipv6 expicitly by -Djava.net.preferIPv4Stack=true,
+         * so we have to call ipv6_available()
+         */
+        if (ipv6_available()) {
 
-        ifs = enumIPv6Interfaces(env, sock, ifs);
-        close(sock);
+           sock =  openSocket(env, AF_INET6);
+           if (sock < 0 && (*env)->ExceptionOccurred(env)) {
+               freeif(ifs);
+               return NULL;
+           }
 
-        if ((*env)->ExceptionOccurred(env)) {
-            freeif(ifs);
-            return NULL;
-        }
+           ifs = enumIPv6Interfaces(env, sock, ifs);
+           close(sock);
+
+           if ((*env)->ExceptionOccurred(env)) {
+              freeif(ifs);
+              return NULL;
+           }
+
+       }
 #endif
 
     return ifs;