public class JNILibLoaderBase extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
JNILibLoaderBase.LoaderAction |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
| Constructor and Description |
|---|
JNILibLoaderBase() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addLoaded(String libName) |
static boolean |
addNativeJarLibs(Class<?>[] classesFromJavaJars,
String singleJarMarker)
Loads and adds a JAR file's native library to the TempJarCache.
|
static boolean |
addNativeJarLibsJoglCfg(Class<?>[] classesFromJavaJars)
Loads and adds a JAR file's native library to the TempJarCache,
calling
addNativeJarLibs(Class[], String)
with default JOGL deployment configuration:
return JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all");
If Class1.class is contained in a JAR file which name includes singleJarMarker -all,
implementation will attempt to resolve the native JAR file as follows:
ClassJar-all.jar to ClassJar-all-natives-os.and.arch.jar
Otherwise the native JAR files will be resolved for each class's JAR file:
ClassJar1.jar to ClassJar1-natives-os.and.arch.jar
ClassJar2.jar to ClassJar2-natives-os.and.arch.jar
.. |
static void |
disableLoading() |
static void |
enableLoading() |
static boolean |
isLoaded(String libName) |
protected static boolean |
loadLibrary(String libname,
boolean ignoreError,
ClassLoader cl)
Loads the library specified by libname, using the
JNILibLoaderBase.LoaderAction set by setLoadingAction(LoaderAction). |
protected static void |
loadLibrary(String libname,
String[] preload,
boolean preloadIgnoreError,
ClassLoader cl)
Loads the library specified by libname, using the
JNILibLoaderBase.LoaderAction set by setLoadingAction(LoaderAction). |
static void |
setLoadingAction(JNILibLoaderBase.LoaderAction action) |
public static boolean isLoaded(String libName)
public static void addLoaded(String libName)
public static void disableLoading()
public static void enableLoading()
public static void setLoadingAction(JNILibLoaderBase.LoaderAction action)
public static final boolean addNativeJarLibsJoglCfg(Class<?>[] classesFromJavaJars)
addNativeJarLibs(Class[], String)
with default JOGL deployment configuration:
return JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all");
If Class1.class is contained in a JAR file which name includes singleJarMarker -all,
implementation will attempt to resolve the native JAR file as follows:
public static boolean addNativeJarLibs(Class<?>[] classesFromJavaJars, String singleJarMarker)
GLProfile.class -> http://lala/gluegen-rt.jar -> http://lala/gluegen-rt -> http://lala/gluegen-rt-natives-'os.and.arch'.jar classesFromJavaJarsGeneric description:
final Class>[] classesFromJavaJars = new Class>[] { Class1.class, Class2.class };
JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all");
If Class1.class is contained in a JAR file which name includes singleJarMarker, here -all,
implementation will attempt to resolve the native JAR file as follows:
Examples:
JOCL:
// only: jocl.jar -> jocl-natives-os.and.arch.jar
addNativeJarLibs(new Class>[] { JOCLJNILibLoader.class }, null, null );
JOGL:
final ClassLoader cl = GLProfile.class.getClassLoader();
// jogl-all.jar -> jogl-all-natives-os.and.arch.jar
// jogl-all-noawt.jar -> jogl-all-noawt-natives-os.and.arch.jar
// jogl-all-mobile.jar -> jogl-all-mobile-natives-os.and.arch.jar
// jogl-all-android.jar -> jogl-all-android-natives-os.and.arch.jar
// nativewindow.jar -> nativewindow-natives-os.and.arch.jar
// jogl.jar -> jogl-natives-os.and.arch.jar
// newt.jar -> newt-natives-os.and.arch.jar (if available)
final String newtFactoryClassName = "com.jogamp.newt.NewtFactory";
final Class>[] classesFromJavaJars = new Class>[] { NWJNILibLoader.class, GLProfile.class, null };
if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) {
classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl);
}
JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all");
classesFromJavaJars - For each given Class, load the native library JAR.singleJarMarker - Optional string marker like "-all" to identify the single 'all-in-one' JAR file
after which processing of the class array shall stop.protected static boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl)
JNILibLoaderBase.LoaderAction set by setLoadingAction(LoaderAction).libname - the library to loadignoreError - if true, errors during loading the library should be ignoredcl - optional ClassLoader, used to locate the libraryprotected static void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError, ClassLoader cl)
JNILibLoaderBase.LoaderAction set by setLoadingAction(LoaderAction).libname - the library to loadpreload - the libraries to load before loading the main library if not nullpreloadIgnoreError - if true, errors during loading the preload-libraries should be ignoredcl - optional ClassLoader, used to locate the library