< prev index next >

src/jdk.net/linux/classes/jdk/internal/net/rdma/LinuxRdmaSocketImpl.java

Print this page

        

@@ -32,23 +32,42 @@
 import sun.net.ext.RdmaSocketOptions;
 import static jdk.internal.net.rdma.RdmaSocketImpl.PlatformRdmaSocketImpl;
 
 class LinuxRdmaSocketImpl extends PlatformRdmaSocketImpl
 {
+    private static final UnsupportedOperationException unsupported;
+
+    private static final Void checkSupported() {
+        if (unsupported != null)
+            throw new UnsupportedOperationException(unsupported.getMessage(), unsupported);
+        else
+            return null;
+    }
+
     static {
         java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<>() {
                 public Void run() {
                     System.loadLibrary("net");
                     System.loadLibrary("extnet");
                     return null;
                 }
             });
+        UnsupportedOperationException uoe = null;
+        try {
         initProto();
+        } catch (UnsupportedOperationException e) {
+            uoe = e;
+        }
+        unsupported = uoe;
+    }
+
+    public LinuxRdmaSocketImpl() {
+        this(checkSupported());
     }
 
-    public LinuxRdmaSocketImpl() { }
+    private LinuxRdmaSocketImpl(Void unused) { }
 
     static final RdmaSocketOptions rdmaOptions =
             RdmaSocketOptions.getInstance();
 
     private static volatile boolean checkedRdma;

@@ -78,11 +97,11 @@
         if (socketInputStream != null) {
             ((RdmaSocketInputStream)socketInputStream).setEOF(true);
         }
     }
 
-    static native void initProto();
+    static native void initProto() throws UnsupportedOperationException;
 
     private static native boolean isRdmaAvailable0();
 
     native void rdmaSocketCreate(RdmaSocketImpl impl) throws IOException;
 
< prev index next >