public final class JNIMethods
extends java.lang.Object
Note on usage: unfortunately it is not possible to provide a loadLibrary(String) method here as it needs to know the calling class, which is lost when wrapped here. To load a native library using this class, call the getPortableLibraryName() method to return a String which may then be passed to System.loadLibrary().
Note: due to the nature of this class, a portable JUnit TestCase is not possible.
Modifier and Type | Class and Description |
---|---|
static class |
JNIMethods.ARCHType
Enumeration of common CPU architectures.
|
static class |
JNIMethods.OSType
Enumeration of common operating systems, independent of version or architecture.
|
Modifier and Type | Field and Description |
---|---|
static JNIMethods.ARCHType |
ARCH
Stores the CPU Architecture the JVM is currently running on.
|
static JNIMethods.OSType |
OS
Stores the operating system the JVM is currently running on.
|
Constructor and Description |
---|
JNIMethods() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getPortableLibraryName(java.lang.String name)
The System.mapLibraryName method is broken in the sense that it does not give
unique names for operating systems and architectures.
|
static void |
main(java.lang.String[] args) |
public static final JNIMethods.ARCHType ARCH
public static final JNIMethods.OSType OS
public static java.lang.String getPortableLibraryName(java.lang.String name)
The resulting filename will be constructed by forcing the library name to lowercase and appending an extra String that is defined by the operating system (the architecture is only encoded if it is relevant). Some examples are for the parameter 'name':-
name
- java.lang.IllegalArgumentException
- if the input name is zero length or contains a directory separator
character.public static void main(java.lang.String[] args)