< prev index next >

src/java.base/share/classes/jdk/internal/loader/BootLoader.java

Print this page
rev 55686 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs, mchung

@@ -127,10 +127,27 @@
             return null;
         }
     }
 
     /**
+     * Loads a library from the system path.
+     */
+    public static void loadLibrary(String library) {
+        if (System.getSecurityManager() == null) {
+            SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
+        } else {
+            AccessController.doPrivileged(
+                new java.security.PrivilegedAction<>() {
+                    public Void run() {
+                        SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
+                        return null;
+                    }
+                });
+        }
+    }
+
+    /**
      * Returns a URL to a resource in a module defined to the boot loader.
      */
     public static URL findResource(String mn, String name) throws IOException {
         return ClassLoaders.bootLoader().findResource(mn, name);
     }
< prev index next >