System.load() and System.loadLibrary()
in general provide suitable functionality for applications using
native code, but are not flexible enough to support certain kinds
of glue code generation and deployment strategies. This class
supports direct linking of native libraries to other shared
objects not necessarily installed on the system (in particular,
via the use of dlopen(RTLD_GLOBAL) on Unix platforms) as well as
manual lookup of function names to support e.g. GlueGen's
ProcAddressTable glue code generation style without additional
supporting code needed in the generated library.
| Modifier and Type | Field and Description |
|---|---|
| private final DynamicLinker | |
| private static Method | |
| private final boolean | |
| private static boolean | |
| private static final boolean | |
| private long | |
| private final String | |
| private static final String[] | |
| private static final String[] |
| Access | Constructor and Description |
|---|---|
| private | NativeLibrary(final DynamicLinker dynLink, final long libraryHandle, final String libraryPath, final boolean global)
|
| Modifier and Type | Method and Description |
|---|---|
| private static final void | |
| private static final String[] | |
| public final void | |
| public final void | |
| public final long | dynamicLookupFunction(final String funcName)
Implements com. |
| public final long | dynamicLookupFunctionGlobal(final String funcName)
Looks up the given function name in all loaded libraries. |
| public static final List | enumerateLibraryPaths(final String windowsLibName, final String unixLibName, final String macOSXLibName, final ClassLoader loader)
Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system not using the system path. |
| public static final List | enumerateLibraryPaths(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPathFirst, final ClassLoader loader)
Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system using the system path. |
| private static final List | enumerateLibraryPaths(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPath, final boolean searchSystemPathFirst, final ClassLoader loader)
|
| public static final String | |
| private static final String | |
| pack-priv final DynamicLinker | |
| public final long | |
| public final String | |
| public final boolean | isFunctionAvailable(final String funcName)
Implements com. |
| public static final String | Returns: basename of libName w/o path, ie. /usr/lib/libDrinkBeer.so -> DrinkBeer on Unix systems, but null on Windows.the full path library name with prefix and suffix libName, final boolean indicates if libName is already lower-case isLowerCaseAlready)Comparison of prefix and suffix of the given libName's basename is performed case insensitive |
| public static final NativeLibrary | open(final String libName, final ClassLoader loader)
Opens the given native library, assuming it has the same base name on all platforms, looking first in the system's search path, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start. |
| public static final NativeLibrary | open(final String libName, final ClassLoader loader, final boolean global)
Opens the given native library, assuming it has the same base name on all platforms, looking first in the system's search path, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start. |
| public static final NativeLibrary | open(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPathFirst, final ClassLoader loader)
Opens the given native library, assuming it has the given base names (no "lib" prefix or ".dll/.so/.dylib" suffix) on the Windows, Unix and Mac OS X platforms, respectively, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start. |
| public static final NativeLibrary | open(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPathFirst, final ClassLoader loader, final boolean global)
|
| public final void | |
| private static final String | |
| public final String |
| dynLink | back to summary |
|---|---|
| private final DynamicLinker dynLink | |
| findLibraryMethod | back to summary |
|---|---|
| private static Method findLibraryMethod | |
| global | back to summary |
|---|---|
| private final boolean global | |
| initializedFindLibraryMethod | back to summary |
|---|---|
| private static boolean initializedFindLibraryMethod | |
| isOSX | back to summary |
|---|---|
| private static final boolean isOSX | |
| libraryHandle | back to summary |
|---|---|
| private long libraryHandle | |
| libraryPath | back to summary |
|---|---|
| private final String libraryPath | |
| prefixes | back to summary |
|---|---|
| private static final String[] prefixes | |
| suffixes | back to summary |
|---|---|
| private static final String[] suffixes | |
| NativeLibrary | back to summary |
|---|---|
| private NativeLibrary(final DynamicLinker dynLink, final long libraryHandle, final String libraryPath, final boolean global) | |
| addPaths | back to summary |
|---|---|
| private static final void addPaths(final String path, final String[] baseNames, final List<String> paths) | |
| buildNames | back to summary |
|---|---|
| private static final String[] buildNames(final String libName) | |
| claimAllLinkPermission | back to summary |
|---|---|
| public final void claimAllLinkPermission() throws SecurityException Implements com.
| |
| close | back to summary |
|---|---|
| public final void close() throws SecurityException Closes this native library. Further lookup operations are not allowed after calling this method.
| |
| dynamicLookupFunction | back to summary |
|---|---|
| public final long dynamicLookupFunction(final String funcName) throws SecurityException Implements com. Doc from com. Returns the function handle for function 'funcName'.
| |
| dynamicLookupFunctionGlobal | back to summary |
|---|---|
| public final long dynamicLookupFunctionGlobal(final String funcName) throws SecurityException Looks up the given function name in all loaded libraries.
| |
| enumerateLibraryPaths | back to summary |
|---|---|
| public static final List Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system not using the system path. | |
| enumerateLibraryPaths | back to summary |
|---|---|
| public static final List Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system using the system path. | |
| enumerateLibraryPaths | back to summary |
|---|---|
| private static final List | |
| findLibrary | back to summary |
|---|---|
| public static final String findLibrary(final String libName, final ClassLoader loader) | |
| findLibraryImpl | back to summary |
|---|---|
| private static final String findLibraryImpl(final String libName, final ClassLoader loader) | |
| getDynamicLinker | back to summary |
|---|---|
| pack-priv final DynamicLinker getDynamicLinker() | |
| getLibraryHandle | back to summary |
|---|---|
| public final long getLibraryHandle() Retrieves the low-level library handle from this NativeLibrary object. On the Windows platform this is an HMODULE, and on Unix and Mac OS X platforms the void* result of calling dlopen(). | |
| getLibraryPath | back to summary |
|---|---|
| public final String getLibraryPath() Retrieves the path under which this library was opened. | |
| isFunctionAvailable | back to summary |
|---|---|
| public final boolean isFunctionAvailable(final String funcName) throws SecurityException Implements com. Doc from com. Queries whether function 'funcName' is available.
| |
| isValidNativeLibraryName | back to summary |
|---|---|
| public static final String isValidNativeLibraryName(final String libName, final boolean isLowerCaseAlready) Comparison of prefix and suffix of the given libName's basename
is performed case insensitive | |
| open | back to summary |
|---|---|
| public static final NativeLibrary open(final String libName, final ClassLoader loader) throws SecurityException Opens the given native library, assuming it has the same base name on all platforms, looking first in the system's search path, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start.
| |
| open | back to summary |
|---|---|
| public static final NativeLibrary open(final String libName, final ClassLoader loader, final boolean global) throws SecurityException Opens the given native library, assuming it has the same base name on all platforms, looking first in the system's search path, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start.
| |
| open | back to summary |
|---|---|
| public static final NativeLibrary open(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPathFirst, final ClassLoader loader) throws SecurityException Opens the given native library, assuming it has the given base names (no "lib" prefix or ".dll/.so/.dylib" suffix) on the Windows, Unix and Mac OS X platforms, respectively, and in the context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start.
The
| |
| open | back to summary |
|---|---|
public static final NativeLibrary open(final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPathFirst, final ClassLoader loader, final boolean global) throws SecurityException
| |
| releaseAllLinkPermission | back to summary |
|---|---|
| public final void releaseAllLinkPermission() throws SecurityException Implements com.
| |
| selectName | back to summary |
|---|---|
| private static final String selectName(final String windowsLibName, final String unixLibName, final String macOSXLibName) | |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object. | |