< prev index next >

src/java.base/share/classes/java/lang/ClassLoader.java

Print this page




2357      * Returns the absolute path name of a native library.  The VM invokes this
2358      * method to locate the native libraries that belong to classes loaded with
2359      * this class loader. If this method returns {@code null}, the VM
2360      * searches the library along the path specified as the
2361      * "{@code java.library.path}" property.
2362      *
2363      * @param  libname
2364      *         The library name
2365      *
2366      * @return  The absolute path of the native library
2367      *
2368      * @see  System#loadLibrary(String)
2369      * @see  System#mapLibraryName(String)
2370      *
2371      * @since  1.2
2372      */
2373     protected String findLibrary(String libname) {
2374         return null;
2375     }
2376 
2377     private final NativeLibraries libraries = new NativeLibraries(this);
2378 
2379     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
2380     static NativeLibrary loadLibrary(Class<?> fromClass, File file) {
2381         ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader();
2382         NativeLibraries libs = loader != null ? loader.libraries : BootLoader.getNativeLibraries();
2383         NativeLibrary nl = libs.loadLibrary(fromClass, file);
2384         if (nl != null) {
2385             return nl;
2386         }
2387         throw new UnsatisfiedLinkError("Can't load library: " + file);
2388     }
2389     static NativeLibrary loadLibrary(Class<?> fromClass, String name) {
2390         ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader();
2391         if (loader == null) {
2392             NativeLibrary nl = BootLoader.getNativeLibraries().loadLibrary(fromClass, name);
2393             if (nl != null) {
2394                 return nl;
2395             }
2396             throw new UnsatisfiedLinkError("no " + name +
2397                     " in system library path: " + StaticProperty.sunBootLibraryPath());




2357      * Returns the absolute path name of a native library.  The VM invokes this
2358      * method to locate the native libraries that belong to classes loaded with
2359      * this class loader. If this method returns {@code null}, the VM
2360      * searches the library along the path specified as the
2361      * "{@code java.library.path}" property.
2362      *
2363      * @param  libname
2364      *         The library name
2365      *
2366      * @return  The absolute path of the native library
2367      *
2368      * @see  System#loadLibrary(String)
2369      * @see  System#mapLibraryName(String)
2370      *
2371      * @since  1.2
2372      */
2373     protected String findLibrary(String libname) {
2374         return null;
2375     }
2376 
2377     private final NativeLibraries libraries = NativeLibraries.jniNativeLibraries(this);
2378 
2379     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
2380     static NativeLibrary loadLibrary(Class<?> fromClass, File file) {
2381         ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader();
2382         NativeLibraries libs = loader != null ? loader.libraries : BootLoader.getNativeLibraries();
2383         NativeLibrary nl = libs.loadLibrary(fromClass, file);
2384         if (nl != null) {
2385             return nl;
2386         }
2387         throw new UnsatisfiedLinkError("Can't load library: " + file);
2388     }
2389     static NativeLibrary loadLibrary(Class<?> fromClass, String name) {
2390         ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader();
2391         if (loader == null) {
2392             NativeLibrary nl = BootLoader.getNativeLibraries().loadLibrary(fromClass, name);
2393             if (nl != null) {
2394                 return nl;
2395             }
2396             throw new UnsatisfiedLinkError("no " + name +
2397                     " in system library path: " + StaticProperty.sunBootLibraryPath());


< prev index next >