NativeLibrary#getProcess()).
Library Search Paths A search for a given library will scan the following locations:
jna.library.path User-customizable path
jna.platform.library.path Platform-specific paths
~/Library/Frameworks,
/Library/Frameworks, and
/System/Library/Frameworks will be searched for a framework
with a name corresponding to that requested. Absolute paths to frameworks
are also accepted, either ending at the framework name (sans ".framework")
or the full path to the framework shared library
(e.g. CoreServices.framework/CoreServices).
${os-prefix}/LIBRARY_FILENAME, where ${os-prefix}
is the OS/Arch prefix returned by Platform#getNativeLibraryResourcePrefix(). If bundled in a jar file, the
resource will be extracted to jna.tmpdir for loading, and
later removed (but only if jna.nounpack is false or not set).
jna.debug_load=true to make
JNA print the steps of its library search to the console.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static Method | |
| private final int | |
| private final Cleaner. | |
| private static final Level | |
| private static final int | |
| private final String | |
| private final Map | |
| private volatile long | |
| private static final Map | |
| private final String | |
| private final String | |
| private static final LinkedHashSet | |
| private static final Logger | |
| private static final SymbolProvider | |
| private final Map | |
| private static final Map | |
| private final SymbolProvider |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static final void | addSearchPath(String
The name of the library to use the path for libraryName, String The path to use when trying to load the library path)Add a path to search for the specified library, ahead of any system paths. |
| private static void | |
| public void | |
| public void | |
| pack-priv static void | |
| private static String | findLibraryPath(String libName, Collection<String> searchPath)
Use standard library search paths to find the library. |
| private static String | |
| public File | |
| public Function | getFunction(String
Name of the native function to be linked with functionName)Create a new |
| pack-priv Function | getFunction(String
Name of the native function to be linked with. Uses a
function mapper option if one was provided to
transform the name. name, Method Method to which the native function is to be mapped method)Create a new |
| public Function | getFunction(String
Name of the native function to be linked with functionName, int Flags affecting the function invocation callFlags)Create a new |
| public Function | getFunction(String
Name of the native function to be linked with functionName, int Flags affecting the function invocation callFlags, String Encoding to use to convert between Java and native
strings. encoding)Create a new |
| public Pointer | Returns: Pointer representing the global variable addressLook up the given global variable within this library. |
| public static final NativeLibrary | getInstance(String
The library name to load.
This can be short form (e.g. "c"),
an explicit version (e.g. "libc.so.6"), or
the full path to the library (e.g. "/lib/libc.so.6"). libraryName)Returns an instance of NativeLibrary for the specified name. |
| public static final NativeLibrary | getInstance(String
The library name to load.
This can be short form (e.g. "c"),
an explicit version (e.g. "libc.so.6"), or
the full path to the library (e.g. "/lib/libc.so.6"). libraryName, ClassLoader The class loader to use to load the native library.
This only affects library loading when the native library is
included somewhere in the classpath, either bundled in a jar file
or as a plain file within the classpath. classLoader)Returns an instance of NativeLibrary for the specified name. |
| public static final NativeLibrary | getInstance(String
The library name to load.
This can be short form (e.g. "c"),
an explicit version (e.g. "libc.so.6" or
"QuickTime.framework/Versions/Current/QuickTime"), or
the full (absolute) path to the library (e.g. "/lib/libc.so.6"). libraryName, Map<String, ?> Native library options for the given library (see libraryOptions)Library).Returns an instance of NativeLibrary for the specified name. |
| private String | |
| private static ArrayList | |
| private static String | |
| public String | |
| public Map | |
| public static final synchronized NativeLibrary | |
| public static final synchronized NativeLibrary | getProcess(Map<String, ?> options)
Returns an instance of NativeLibrary which refers to the current process. |
| pack-priv long | |
| private static List | |
| private static boolean | |
| private static NativeLibrary | |
| pack-priv static String | mapSharedLibraryName(String
base (undecorated) name of library libName)Similar to |
| pack-priv static String[] | |
| pack-priv static String | matchLibrary(final String libName, Collection<String> searchPath)
matchLibrary() is very Linux specific. |
| private static int | |
| pack-priv static double | |
| public String |
| addSuppressedMethod | back to summary |
|---|---|
| private static Method addSuppressedMethod | |
| callFlags | back to summary |
|---|---|
| private final int callFlags | |
| cleanable | back to summary |
|---|---|
| private final Cleaner. | |
| DEBUG_LOAD_LEVEL | back to summary |
|---|---|
| private static final Level DEBUG_LOAD_LEVEL | |
| DEFAULT_OPEN_OPTIONS | back to summary |
|---|---|
| private static final int DEFAULT_OPEN_OPTIONS | |
| encoding | back to summary |
|---|---|
| private final String encoding | |
| functions | back to summary |
|---|---|
| private final Map<String, Function> functions | |
| handle | back to summary |
|---|---|
| private volatile long handle | |
| libraries | back to summary |
|---|---|
| private static final Map<String, Reference<NativeLibrary>> libraries | |
| libraryName | back to summary |
|---|---|
| private final String libraryName | |
| libraryPath | back to summary |
|---|---|
| private final String libraryPath | |
| librarySearchPath | back to summary |
|---|---|
| private static final LinkedHashSet<String> librarySearchPath | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| NATIVE_SYMBOL_PROVIDER | back to summary |
|---|---|
| private static final SymbolProvider NATIVE_SYMBOL_PROVIDER | |
| options | back to summary |
|---|---|
| private final Map<String, ?> options | |
| searchPaths | back to summary |
|---|---|
| private static final Map<String, List<String>> searchPaths | |
| symbolProvider | back to summary |
|---|---|
| private final SymbolProvider symbolProvider | |
| NativeLibrary | back to summary |
|---|---|
private NativeLibrary(String libraryName, String libraryPath, long handle, Map<String, ?> options)
| |
| addSearchPath | back to summary |
|---|---|
| public static final void addSearchPath(String libraryName, String path) Add a path to search for the specified library, ahead of any system
paths. This is similar to setting | |
| addSuppressedReflected | back to summary |
|---|---|
| private static void addSuppressedReflected(Throwable target, Throwable suppressed) | |
| close | back to summary |
|---|---|
| public void close() Implements java. Close the native library we're mapped to. | |
| dispose | back to summary |
|---|---|
| public void dispose()
Deprecated
| |
| disposeAll | back to summary |
|---|---|
| pack-priv static void disposeAll() Close all open native libraries. | |
| findLibraryPath | back to summary |
|---|---|
| private static String findLibraryPath(String libName, Collection<String> searchPath) Use standard library search paths to find the library. | |
| functionKey | back to summary |
|---|---|
| private static String functionKey(String name, int flags, String encoding) | |
| getFile | back to summary |
|---|---|
| public File getFile() Returns the file on disk corresponding to this NativeLibrary instance. If this NativeLibrary represents the current process, this function will return null. | |
| getFunction | back to summary |
|---|---|
| public Function getFunction(String functionName) Create a new The allocated instance represents a pointer to the named native function from the library.
| |
| getFunction | back to summary |
|---|---|
| pack-priv Function getFunction(String name, Method method) Create a new The allocated instance represents a pointer to the named native function from the library.
| |
| getFunction | back to summary |
|---|---|
| public Function getFunction(String functionName, int callFlags) Create a new
| |
| getFunction | back to summary |
|---|---|
| public Function getFunction(String functionName, int callFlags, String encoding) Create a new
| |
| getGlobalVariableAddress | back to summary |
|---|---|
| public Pointer getGlobalVariableAddress(String symbolName) Look up the given global variable within this library.
| |
| getInstance | back to summary |
|---|---|
| public static final NativeLibrary getInstance(String libraryName) Returns an instance of NativeLibrary for the specified name. The library is loaded if not already loaded. If already loaded, the existing instance is returned. More than one name may map to the same NativeLibrary instance; only a single instance will be provided for any given unique file path.
| |
| getInstance | back to summary |
|---|---|
| public static final NativeLibrary getInstance(String libraryName, ClassLoader classLoader) Returns an instance of NativeLibrary for the specified name. The library is loaded if not already loaded. If already loaded, the existing instance is returned. More than one name may map to the same NativeLibrary instance; only a single instance will be provided for any given unique file path.
| |
| getInstance | back to summary |
|---|---|
| public static final NativeLibrary getInstance(String libraryName, Map<String, ?> libraryOptions) Returns an instance of NativeLibrary for the specified name. The library is loaded if not already loaded. If already loaded, the existing instance is returned. More than one name may map to the same NativeLibrary instance; only a single instance will be provided for any given unique file path.
| |
| getLibraryName | back to summary |
|---|---|
| private String getLibraryName(String libraryName) | |
| getLinuxLdPaths | back to summary |
|---|---|
| private static ArrayList Get the library paths from ldconfig cache. Tested against ldconfig 2.13. | |
| getMultiArchPath | back to summary |
|---|---|
| private static String getMultiArchPath() | |
| getName | back to summary |
|---|---|
| public String getName() Returns the simple name of this library. | |
| getOptions | back to summary |
|---|---|
| public Map | |
| getProcess | back to summary |
|---|---|
| public static final synchronized NativeLibrary getProcess() Returns an instance of NativeLibrary which refers to the current process. This is useful for accessing functions which were already mapped by some other mechanism, without having to reference or even know the exact name of the native library. | |
| getProcess | back to summary |
|---|---|
| public static final synchronized NativeLibrary getProcess(Map<String, ?> options) Returns an instance of NativeLibrary which refers to the current process. This is useful for accessing functions which were already mapped by some other mechanism, without having to reference or even know the exact name of the native library. | |
| getSymbolAddress | back to summary |
|---|---|
| pack-priv long getSymbolAddress(String name) Used by the Function class to locate a symbol
| |
| initPaths | back to summary |
|---|---|
| private static List | |
| isVersionedName | back to summary |
|---|---|
| private static boolean isVersionedName(String name) | |
| loadLibrary | back to summary |
|---|---|
| private static NativeLibrary loadLibrary(final String libraryName, final Map<String, ?> options) | |
| mapSharedLibraryName | back to summary |
|---|---|
| pack-priv static String mapSharedLibraryName(String libName) Similar to
| |
| matchFramework | back to summary |
|---|---|
| pack-priv static String[] matchFramework(String libraryName) Look for a matching framework (OSX) | |
| matchLibrary | back to summary |
|---|---|
| pack-priv static String matchLibrary(final String libName, Collection<String> searchPath) matchLibrary() is very Linux specific. It is here to deal with the case where /usr/lib/libc.so does not exist, or it is not a valid symlink to a versioned file (e.g. /lib/libc.so.6). | |
| openFlags | back to summary |
|---|---|
| private static int openFlags(Map<String, ?> options) | |
| parseVersion | back to summary |
|---|---|
| pack-priv static double parseVersion(String ver) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void |
| handle | back to summary |
|---|---|
| private long handle | |
| NativeLibraryDisposer | back to summary |
|---|---|
| public NativeLibraryDisposer(long handle) | |
| run | back to summary |
|---|---|
| public synchronized void run() Implements java. Doc from java. Runs this operation. | |