APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.loader

public final Class RawNativeLibraries

extends Object
Class Inheritance
Imports
jdk.internal.misc.VM, java.io.IOException, java.lang.invoke.MethodHandles, java.nio.file.Path, java.util.Objects, .Set, java.util.concurrent.ConcurrentHashMap

RawNativeLibraries has the following properties: 1. Native libraries loaded in this RawNativeLibraries instance are not JNI native libraries. Hence JNI_OnLoad and JNI_OnUnload will be ignored. No support for linking of native method. 2. Native libraries not auto-unloaded. They may be explicitly unloaded via NativeLibraries::unload. 3. No relationship with class loaders.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final Class<?>
pack-priv final Set<RawNativeLibraries.RawNativeLibraryImpl>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public NativeLibrary
load(Path path)

public NativeLibrary
load(String
the pathname of the native library
pathname
)

Load a native library of the given pathname, which is platform-specific.

private static native boolean
public static RawNativeLibraries
newInstance(MethodHandles.Lookup trustedCaller)

Creates a RawNativeLibraries instance that has no relationship with any class loaders and disabled auto unloading.

public void
private static native void
unload0(String name, long handle)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callerback to summary
pack-priv final Class<?> caller
librariesback to summary
pack-priv final Set<RawNativeLibraries.RawNativeLibraryImpl> libraries

Constructor Detail

RawNativeLibrariesback to summary
private RawNativeLibraries(MethodHandles.Lookup trustedCaller)

Method Detail

loadback to summary
public NativeLibrary load(Path path)
loadback to summary
public NativeLibrary load(String pathname)

Load a native library of the given pathname, which is platform-specific. Returns null if it fails to load the given pathname. If the given pathname does not contain a name-separator character, for example on Unix a slash character, the library search strategy is system-dependent for example on Unix, see dlopen.

API Note

The pathname argument is platform-specific. System#mapLibraryName can be used to convert a name to a platform-specific pathname:

RawNativeLibraries libs = RawNativeLibraries.newInstance(MethodHandles.lookup()); NativeLibrary lib = libs.load(System.mapLibraryName("blas"));
RawNativeLibraries libs = RawNativeLibraries.newInstance(MethodHandles.lookup());
NativeLibrary lib = libs.load(System.mapLibraryName("blas"));
The library is opened with the platform-specific library loading mechanism. If this method is called with the same pathname multiple times, the library is opened the same number of times. To close the library of the given path, #unload must be called on all the NativeLibrary instances that load it.
Parameters
pathname:String

the pathname of the native library

See Also
System#mapLibraryName(String)
load0back to summary
private static native boolean load0(RawNativeLibraries.RawNativeLibraryImpl impl, String name)
newInstanceback to summary
public static RawNativeLibraries newInstance(MethodHandles.Lookup trustedCaller)

Creates a RawNativeLibraries instance that has no relationship with any class loaders and disabled auto unloading. This static factory method is restricted for JDK trusted class use.

unloadback to summary
public void unload(NativeLibrary lib)
unload0back to summary
private static native void unload0(String name, long handle)
jdk.internal.loader back to summary

pack-priv Class RawNativeLibraries.RawNativeLibraryImpl

extends NativeLibrary
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public long
find(String name)

Implements abstract jdk.internal.loader.NativeLibrary.find.

Finds the address of the entry of the given name.

public String
pack-priv boolean
open()

Inherited from jdk.internal.loader.NativeLibrary:
findEntry0lookup

Field Detail

handleback to summary
pack-priv long handle
nameback to summary
pack-priv final String name

Constructor Detail

RawNativeLibraryImplback to summary
pack-priv RawNativeLibraryImpl(String name)

Method Detail

closeback to summary
pack-priv void close()
findback to summary
public long find(String name)

Implements abstract jdk.internal.loader.NativeLibrary.find.

Doc from jdk.internal.loader.NativeLibrary.find.

Finds the address of the entry of the given name. Returns 0 if not found.

Annotations
@Override
nameback to summary
public String name()

Implements abstract jdk.internal.loader.NativeLibrary.name.

Annotations
@Override
openback to summary
pack-priv boolean open()