getTypeMapper and getStructureAlignment are provided
to avoid having to explicitly pass these parameters to Structures,
which would require every Structure which requires custom mapping
or alignment to define a constructor and pass parameters to the superclass.
To avoid lots of boilerplate, the base Structure constructor
figures out these properties based on its enclosing interface.
System#loadLibrary. If not found, the appropriate library
will be extracted from the class path into a temporary directory and
loaded from there. If your system has additional security constraints
regarding execution or load of files (SELinux, for example), you should
probably install the native library in an accessible location and configure
your system accordingly, rather than relying on JNA to extract the library
from its own jar file.
Library
| Modifier and Type | Class and Description |
|---|---|
| public static class | Native.W32Cleanup
For internal use only. |
| Modifier and Type | Field and Description |
|---|---|
| private static Map | |
| private static final ThreadLocal | |
| private static Map | |
| public static final int | LONG_SIZE
Size of a native |
| private static Map | |
| public static final int | POINTER_SIZE
The size of a native pointer ( |
| private static Map | |
| public static final int | WCHAR_SIZE
Size of a native |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static Class | |
| private static native String | |
| public static Pointer | getByteBufferPointer(ByteBuffer b)
Deprecated
Use
Convert a direct getDirectBufferPointer instead.
Buffer into a Pointer.
|
| pack-priv static byte[] | |
| public static long | getComponentID(Component c)
Utility method to get the native window ID for a heavyweight Java
|
| public static Pointer | getComponentPointer(Component c)
Utility method to get the native window pointer for a heavyweight Java
|
| public static native Pointer | |
| public static int | |
| public static Map | getLibraryOptions(Class<T> type)
Return the preferred native library configuration options for the given class. |
| private static String | |
| public static int | |
| private static native String | |
| public static synchronized native boolean | getPreserveLastError()
Indicates whether the system last error result is preserved after every invocation. |
| public static int | getStructureAlignment(Class<T> cls)
Return the preferred structure alignment for the given native interface. |
| public static TypeMapper | |
| public static String | getWebStartLibraryPath(String libName)
If running web start, determine the location of a given native library. |
| private static native long | |
| public static long | |
| public static Pointer | getWindowPointer(Window w)
Utility method to get the native window pointer for a Java
|
| private static native void | |
| public static synchronized native boolean | |
| public static boolean | isSupportedNativeType(Class<T> cls)
Indicate whether the given class is supported as a native argument type. |
| private static boolean | loadInstance(Class<T> cls)
Attempts to force initialization of an instance of the library interface by loading a public static field of the requisite type. |
| public static Object | loadLibrary(String name, Class<T> interfaceClass)
Load a library interface from the given shared library, providing the explicit interface class. |
| public static Object | loadLibrary(String name, Class<T> interfaceClass, Map<K, V>
Map of library options libOptions)Load a library interface from the given shared library, providing the explicit interface class and a map of options for the library. |
| private static void | |
| private static native int | |
| public static void | |
| private static native int | |
| public static native void | |
| public static synchronized native void | setPreserveLastError(boolean enable)
Set whether the system last error result is captured after every native invocation. |
| public static synchronized native void | |
| public static Library | Returns: a synchronized view of the specified library.the library to be "wrapped" in a synchronized library. library)Returns a synchronized (thread-safe) library backed by the specified library. |
| public static String | |
| public static String | |
| pack-priv static void | |
| private static native int |
| alignments | back to summary |
|---|---|
| private static Map<K, V> alignments | |
| lastError | back to summary |
|---|---|
| private static final ThreadLocal<T> lastError | |
| libraries | back to summary |
|---|---|
| private static Map<K, V> libraries | |
| LONG_SIZE | back to summary |
|---|---|
| public static final int LONG_SIZE Size of a native | |
| options | back to summary |
|---|---|
| private static Map<K, V> options | |
| POINTER_SIZE | back to summary |
|---|---|
| public static final int POINTER_SIZE The size of a native pointer ( | |
| typeMappers | back to summary |
|---|---|
| private static Map<K, V> typeMappers | |
| WCHAR_SIZE | back to summary |
|---|---|
| public static final int WCHAR_SIZE Size of a native | |
| Native | back to summary |
|---|---|
| private Native() | |
| findLibraryClass | back to summary |
|---|---|
| pack-priv static Class Find the library interface corresponding to the given class. Checks
all ancestor classes for a declaring class which implements
| |
| getAPIChecksum | back to summary |
|---|---|
| private static native String getAPIChecksum() | |
| getByteBufferPointer | back to summary |
|---|---|
| public static Pointer getByteBufferPointer(ByteBuffer b)
Deprecated Use Convert a direct
| |
| getBytes | back to summary |
|---|---|
| pack-priv static byte[] getBytes(String s) Return a byte array corresponding to the given String. If the
system property | |
| getComponentID | back to summary |
|---|---|
| public static long getComponentID(Component c) throws HeadlessException Utility method to get the native window ID for a heavyweight Java
| |
| getComponentPointer | back to summary |
|---|---|
| public static Pointer getComponentPointer(Component c) throws HeadlessException Utility method to get the native window pointer for a heavyweight Java
| |
| getDirectBufferPointer | back to summary |
|---|---|
| public static native Pointer getDirectBufferPointer(Buffer b) Convert a direct
| |
| getLastError | back to summary |
|---|---|
| public static int getLastError() Retrieve the last error set by the OS. This corresponds to
| |
| getLibraryOptions | back to summary |
|---|---|
| public static Map Return the preferred native library configuration options for the given class.
| |
| getNativeLibraryResourcePath | back to summary |
|---|---|
| private static String getNativeLibraryResourcePath() | |
| getNativeSize | back to summary |
|---|---|
| public static int getNativeSize(Class<T> cls) Returns the native size for a given Java class. Structures are
assumed to be | |
| getNativeVersion | back to summary |
|---|---|
| private static native String getNativeVersion() | |
| getPreserveLastError | back to summary |
|---|---|
| public static synchronized native boolean getPreserveLastError() Indicates whether the system last error result is preserved after every invocation. | |
| getStructureAlignment | back to summary |
|---|---|
| public static int getStructureAlignment(Class<T> cls) Return the preferred structure alignment for the given native interface.
| |
| getTypeMapper | back to summary |
|---|---|
| public static TypeMapper getTypeMapper(Class<T> cls) Return the preferred
| |
| getWebStartLibraryPath | back to summary |
|---|---|
| public static String getWebStartLibraryPath(String libName) If running web start, determine the location of a given native
library. This value may be used to properly set
Use
| |
| getWindowHandle0 | back to summary |
|---|---|
| private static native long getWindowHandle0(Component c) | |
| getWindowID | back to summary |
|---|---|
| public static long getWindowID(Window w) throws HeadlessException Utility method to get the native window ID for a Java
| |
| getWindowPointer | back to summary |
|---|---|
| public static Pointer getWindowPointer(Window w) throws HeadlessException Utility method to get the native window pointer for a Java
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() | |
| isProtected | back to summary |
|---|---|
| public static synchronized native boolean isProtected() Returns whether protection is enabled. Check the result of this method
after calling | |
| isSupportedNativeType | back to summary |
|---|---|
| public static boolean isSupportedNativeType(Class<T> cls) Indicate whether the given class is supported as a native argument type. | |
| loadInstance | back to summary |
|---|---|
| private static boolean loadInstance(Class<T> cls) Attempts to force initialization of an instance of the library interface by loading a public static field of the requisite type. Returns whether an instance variable was instantiated. Expects that lock on libraries is already held | |
| loadLibrary | back to summary |
|---|---|
| public static Object loadLibrary(String name, Class<T> interfaceClass) Load a library interface from the given shared library, providing the explicit interface class. | |
| loadLibrary | back to summary |
|---|---|
| public static Object loadLibrary(String name, Class<T> interfaceClass, Map<K, V> libOptions) Load a library interface from the given shared library, providing the explicit interface class and a map of options for the library. If no library options are detected the map is interpreted as a map of Java method names to native function names.
| |
| loadNativeLibrary | back to summary |
|---|---|
| private static void loadNativeLibrary() | |
| longSize | back to summary |
|---|---|
| private static native int longSize() Return the size of a native | |
| main | back to summary |
|---|---|
| public static void main(String[] args) Prints JNA library details to the console. | |
| pointerSize | back to summary |
|---|---|
| private static native int pointerSize() Initialize field and method IDs for native methods of this class. Returns the size of a native pointer. | |
| setLastError | back to summary |
|---|---|
| public static native void setLastError(int code) Set the OS last error code. Whether the setting is per-thread or global depends on the underlying OS. | |
| setPreserveLastError | back to summary |
|---|---|
| public static synchronized native void setPreserveLastError(boolean enable) Set whether the system last error result is captured after every
native invocation. Defaults to | |
| setProtected | back to summary |
|---|---|
| public static synchronized native void setProtected(boolean enable) Set whether native memory accesses are protected from invalid
accesses. This should only be set true when testing or debugging,
and should not be considered reliable or robust for multithreaded
applications. Protected mode will be automatically set if the
system property If not supported by the underlying platform, this setting will have no effect. | |
| synchronizedLibrary | back to summary |
|---|---|
| public static Library synchronizedLibrary(final Library library) Returns a synchronized (thread-safe) library backed by the specified
library. This wrapping will prevent simultaneous invocations of any
functions mapped to a given
| |
| toString | back to summary |
|---|---|
| public static String toString(byte[] buf) Obtain a Java String from the given native byte array. If there is
no NUL terminator, the String will comprise the entire array. If the
system property | |
| toString | back to summary |
|---|---|
| public static String toString(char[] buf) Obtain a Java String from the given native wchar_t array. If there is no NUL terminator, the String will comprise the entire array. | |
| updateLastError | back to summary |
|---|---|
| pack-priv static void updateLastError(int e) Update the last error value (called from native code). | |
| wideCharSize | back to summary |
|---|---|
| private static native int wideCharSize() Return the size of a native | |
| Modifier and Type | Field and Description |
|---|---|
| private File |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| public void | run()
Overrides java. Implements java. |
| file | back to summary |
|---|---|
| private File file | |
| W32Cleanup | back to summary |
|---|---|
| public W32Cleanup(File file) | |
| main | back to summary |
|---|---|
| public static void main(String[] args) | |
| run | back to summary |
|---|---|
| public void run() Overrides java. Implements java. Doc from java. This method is run by the thread when it executes. Subclasses of This method is not intended to be invoked directly. If this thread is a
platform thread created with a | |