|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jniwrapper.Library
public class Library
This class provides operations with a native code library. The
Library
class is responsible for providing the
Function
class instances that are used for calling functions
from native code libraries. Unlike standard functionality provided, a library
can be dynamically loaded and unloaded.
To unload the library you can extend this class and use its unload()
method.
Field Summary | |
---|---|
static java.lang.String |
NATIVE_CODE
|
static java.lang.String |
NATIVE_NAME
|
Constructor Summary | |
---|---|
Library(java.lang.String name)
Constructs a library using its name. |
|
Library(java.lang.String libraryName,
byte callingConvention)
Constructs a library using its name and default calling convention. |
Method Summary | |
---|---|
static void |
ensureNativeCode()
Ensures that the native code implementation is loaded. |
static LibraryLoader |
getDefaultLibraryLoader()
Returns a library loader used in methods that do not take the library loader as an argument. |
Function |
getFunction(java.lang.String name)
A convenience method for getting a function when parameter types do affect loaded function. |
Function |
getFunction(java.lang.String name,
java.lang.Class[] paramTypes)
This returns a Function object that reflects the exported
native function from the library. |
static Library |
getJNIWrapperLibrary()
Returns the instance of loaded JNIWrapper library. |
protected static java.util.List |
getJVMLibraries()
Returns the list of libraries which were loaded by JVM. |
LibraryLoader |
getLibraryLoader()
This method returns the loader of this library. |
java.lang.String |
getName()
Returns the library name. |
void |
getVariable(java.lang.String name,
Parameter variable)
Maps variable to memory address of a global variable in library. |
boolean |
isLoaded()
Returns loaded status of this library. |
void |
load()
Loads a library by its name using default mechanism. |
void |
load(java.lang.ClassLoader classLoader)
Special method for loading a library from the context of the specified class loader. |
void |
load(java.io.File directory)
Loads a library from the passed directory. |
void |
load(LibraryLoader loader)
Loads a library using a given library loader. |
static void |
loadNativeCode()
Initializes the native support library using standard library search behavior and predefined native library name. |
static void |
loadNativeCode(LibraryLoader loader)
Loads a native support library using a specified library loader. |
static void |
loadNativeCode(java.lang.String nativeSupportPath)
Loads a native support library from the passed full file name. |
static void |
setDefaultLibraryLoader(LibraryLoader libraryLoader)
Sets a library loader used in methods that do not take the library loader as an argument. |
protected void |
unload()
This method is designed for unloading an unused library. |
static java.lang.String |
unloadNativeCode()
Unloads JNI library from the Java classloader. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NATIVE_CODE
public static final java.lang.String NATIVE_NAME
Constructor Detail |
---|
public Library(java.lang.String libraryName, byte callingConvention)
libraryName
- the name of the librarycallingConvention
- specifies the calling convention for all functions from this librarypublic Library(java.lang.String name)
name
- library nameMethod Detail |
---|
public static Library getJNIWrapperLibrary()
protected static java.util.List getJVMLibraries()
public static java.lang.String unloadNativeCode()
public static void loadNativeCode(LibraryLoader loader) throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
java.lang.SecurityException
java.lang.UnsatisfiedLinkError
public static void loadNativeCode(java.lang.String nativeSupportPath) throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
java.lang.SecurityException
java.lang.UnsatisfiedLinkError
public static void loadNativeCode() throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
java.lang.SecurityException
java.lang.UnsatisfiedLinkError
public static void ensureNativeCode()
public void load() throws LibraryNotFoundException
LibraryNotFoundException
public void load(java.io.File directory) throws LibraryNotFoundException
LibraryNotFoundException
public void load(LibraryLoader loader) throws LibraryNotFoundException
LibraryNotFoundException
public void load(java.lang.ClassLoader classLoader)
getLibraryLoader
function.
classLoader
- a class loader is the context to load the native library fromprotected void unload()
public boolean isLoaded()
public java.lang.String getName()
public Function getFunction(java.lang.String name, java.lang.Class[] paramTypes) throws NoSuchFunctionException, LibraryNotFoundException
Function
object that reflects the exported
native function from the library.
NoSuchFunctionException
LibraryNotFoundException
public Function getFunction(java.lang.String name) throws NoSuchFunctionException, LibraryNotFoundException
NoSuchFunctionException
LibraryNotFoundException
public void getVariable(java.lang.String name, Parameter variable) throws NoSuchVariableException
#define
operator in a header file,
but only those variables, which are specially declared as global variables, for example:
extern "C" __declspec(dllexport) Type Name;
name
- a variable namevariable
- a variable to load
NoSuchVariableException
public LibraryLoader getLibraryLoader()
public static LibraryLoader getDefaultLibraryLoader()
public static void setDefaultLibraryLoader(LibraryLoader libraryLoader)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |