< 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


 112      * Loads the Class object with the given name defined to the boot loader.
 113      */
 114     public static Class<?> loadClassOrNull(String name) {
 115         return ClassLoaders.bootLoader().loadClassOrNull(name);
 116     }
 117 
 118     /**
 119      * Loads the Class object with the given name in the given module
 120      * defined to the boot loader. Returns {@code null} if not found.
 121      */
 122     public static Class<?> loadClass(Module module, String name) {
 123         Class<?> c = loadClassOrNull(name);
 124         if (c != null && c.getModule() == module) {
 125             return c;
 126         } else {
 127             return null;
 128         }
 129     }
 130 
 131     /**

















 132      * Returns a URL to a resource in a module defined to the boot loader.
 133      */
 134     public static URL findResource(String mn, String name) throws IOException {
 135         return ClassLoaders.bootLoader().findResource(mn, name);
 136     }
 137 
 138     /**
 139      * Returns an input stream to a resource in a module defined to the
 140      * boot loader.
 141      */
 142     public static InputStream findResourceAsStream(String mn, String name)
 143         throws IOException
 144     {
 145         return ClassLoaders.bootLoader().findResourceAsStream(mn, name);
 146     }
 147 
 148     /**
 149      * Returns the URL to the given resource in any of the modules
 150      * defined to the boot loader and the boot class path.
 151      */




 112      * Loads the Class object with the given name defined to the boot loader.
 113      */
 114     public static Class<?> loadClassOrNull(String name) {
 115         return ClassLoaders.bootLoader().loadClassOrNull(name);
 116     }
 117 
 118     /**
 119      * Loads the Class object with the given name in the given module
 120      * defined to the boot loader. Returns {@code null} if not found.
 121      */
 122     public static Class<?> loadClass(Module module, String name) {
 123         Class<?> c = loadClassOrNull(name);
 124         if (c != null && c.getModule() == module) {
 125             return c;
 126         } else {
 127             return null;
 128         }
 129     }
 130 
 131     /**
 132      * Loads a library from the system path.
 133      */
 134     public static void loadLibrary(String library) {
 135         if (System.getSecurityManager() == null) {
 136             SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
 137         } else {
 138             AccessController.doPrivileged(
 139                 new java.security.PrivilegedAction<>() {
 140                     public Void run() {
 141                         SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
 142                         return null;
 143                     }
 144                 });
 145         }
 146     }
 147 
 148     /**
 149      * Returns a URL to a resource in a module defined to the boot loader.
 150      */
 151     public static URL findResource(String mn, String name) throws IOException {
 152         return ClassLoaders.bootLoader().findResource(mn, name);
 153     }
 154 
 155     /**
 156      * Returns an input stream to a resource in a module defined to the
 157      * boot loader.
 158      */
 159     public static InputStream findResourceAsStream(String mn, String name)
 160         throws IOException
 161     {
 162         return ClassLoaders.bootLoader().findResourceAsStream(mn, name);
 163     }
 164 
 165     /**
 166      * Returns the URL to the given resource in any of the modules
 167      * defined to the boot loader and the boot class path.
 168      */


< prev index next >