test/jdk/java/nio/channels/unixdomain/SocketOptions.java
branchunixdomainchannels
changeset 59073 832b8a28e17f
parent 59052 15e9a570c6e6
--- a/test/jdk/java/nio/channels/unixdomain/SocketOptions.java	Wed Nov 13 11:37:09 2019 +0000
+++ b/test/jdk/java/nio/channels/unixdomain/SocketOptions.java	Thu Nov 14 08:27:28 2019 +0000
@@ -42,10 +42,25 @@
 public class SocketOptions {
 
     public static void main(String args[]) throws Exception {
+        if (!supported()) {
+            System.out.println("Unix domain channels not supported");
+            return;
+        }
         test(ServerSocketChannel.open(StandardProtocolFamily.UNIX));
         test(SocketChannel.open(StandardProtocolFamily.UNIX));
     }
 
+    static boolean supported() {
+	try {
+	    SocketChannel.open(StandardProtocolFamily.UNIX);
+	} catch (UnsupportedAddressTypeException e) {
+	    return false;
+	} catch (Exception e) {
+	    return true; // continue test to see what problem is
+	}
+	return true;
+    }
+
     @SuppressWarnings("unchecked")
     public static void test(NetworkChannel chan) throws IOException {
         System.out.println("Checking: " + chan.getClass());