Top Inners Fields Constructors Methods
com.jogamp.common.jvm

public Class JNILibLoaderBase

extends Object
Class Inheritance
Known Direct Subclasses
com.jogamp.common.os.DynamicLibraryBundle.GlueJNILibLoader
Imports
java.io.IOException, java.lang.reflect.InvocationTargetException, .Method, java.net.URISyntaxException, .URL, java.security.AccessController, .PrivilegedAction, java.util.Arrays, .HashSet, .Iterator, .List, com.jogamp.common.net.Uri, com.jogamp.common.os.NativeLibrary, com.jogamp.common.util.JarUtil, .PropertyAccess, com.jogamp.common.util.cache.TempJarCache, jogamp.common.Debug, jogamp.common.os.PlatformPropsImpl

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static interface

Field Summary

Modifier and TypeField and Description
private static final Method
public static final boolean
private static final HashSet<String>
private static JNILibLoaderBase.LoaderAction
private static final String
protected static final boolean
private static long
private static final Object
private static long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
addLoaded(final String libName)

public static boolean

Returns:

true if either the 'all-in-one' native JAR or all native JARs loaded successful or were loaded already, false in case of an error
addNativeJarLibs
(final Class<?>[]
For each given Class, load the native library JAR.
classesFromJavaJars
,
final String
Optional string marker like "-all" to identify the single 'all-in-one' JAR file after which processing of the class array shall stop.
singleJarMarker
)

Loads and adds a JAR file's native library to the TempJarCache.

private static final boolean
addNativeJarLibsImpl(final Class<?> classFromJavaJar, final Uri classJarUri, final Uri.Encoded
jar basename w/ suffix
jarBasename
,
final Uri.Encoded
native jar basename w/ suffix
nativeJarBasename
)

public static final boolean
addNativeJarLibsJoglCfg(final Class<?>[] classesFromJavaJars)

Loads and adds a JAR file's native library to the TempJarCache, calling JNILibLoaderBase#addNativeJarLibs(Class[], String) with default JOGL deployment configuration:

       return JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all");
private static boolean
addNativeJarLibsWithTempJarCache(final Class<?>[] classesFromJavaJars, final String singleJarMarker)

public static void
public static void
public static boolean
isLoaded(final String libName)

protected static synchronized boolean

Returns:

true if library loaded successful
loadLibrary
(final String
the library to load
libname
,
final boolean
if true, errors during loading the library should be ignored
ignoreError
,
final ClassLoader
optional ClassLoader, used to locate the library
cl
)

Loads the library specified by libname, using the LoaderAction set by setLoadingAction(LoaderAction).

protected static synchronized void
loadLibrary(final String
the library to load
libname
,
final String[]
the libraries to load before loading the main library if not null
preload
,
final boolean
if true, errors during loading the preload-libraries should be ignored
preloadIgnoreError
,
final ClassLoader
optional ClassLoader, used to locate the library
cl
)

Loads the library specified by libname, using the LoaderAction set by setLoadingAction(LoaderAction).

private static void
loadLibraryInternal(final String libraryName, final ClassLoader cl)

public static synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

customLoadLibraryMethodback to summary
private static final Method customLoadLibraryMethod
DEBUGback to summary
public static final boolean DEBUG
loadedback to summary
private static final HashSet<String> loaded
loaderActionback to summary
private static JNILibLoaderBase.LoaderAction loaderAction
nativeJarTagPackageback to summary
private static final String nativeJarTagPackage
PERFback to summary
protected static final boolean PERF
perfCountback to summary
private static long perfCount
perfSyncback to summary
private static final Object perfSync
perfTotalback to summary
private static long perfTotal

Constructor Detail

JNILibLoaderBaseback to summary
public JNILibLoaderBase()

Method Detail

addLoadedback to summary
public static void addLoaded(final String libName)
addNativeJarLibsback to summary
public static boolean addNativeJarLibs(final Class<?>[] classesFromJavaJars, final String singleJarMarker)

Loads and adds a JAR file's native library to the TempJarCache.
The native library JAR file's URI is derived as follows:

  • [1] GLProfile.class ->
  • [2] http://lala/gluegen-rt.jar ->
  • [3] http://lala/gluegen-rt ->
  • [4] http://lala/gluegen-rt-natives-'os.and.arch'.jar
Where:
  • [1] is one of classesFromJavaJars
  • [2] is it's complete URI
  • [3] is it's base URI
  • [4] is the derived native JAR filename

Generic 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:
  • 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:
  • Class1Jar.jar to Class1Jar-natives-os.and.arch.jar
  • Class2Jar.jar to Class2Jar-natives-os.and.arch.jar

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");

Parameters
classesFromJavaJars:Class<?>[]

For each given Class, load the native library JAR.

singleJarMarker:String

Optional string marker like "-all" to identify the single 'all-in-one' JAR file after which processing of the class array shall stop.

Returns:boolean

true if either the 'all-in-one' native JAR or all native JARs loaded successful or were loaded already, false in case of an error

addNativeJarLibsImplback to summary
private static final boolean addNativeJarLibsImpl(final Class<?> classFromJavaJar, final Uri classJarUri, final Uri.Encoded jarBasename, final Uri.Encoded nativeJarBasename) throws IOException, SecurityException, URISyntaxException
Parameters
jarBasename:Uri.Encoded

jar basename w/ suffix

nativeJarBasename:Uri.Encoded

native jar basename w/ suffix

addNativeJarLibsJoglCfgback to summary
public static final boolean addNativeJarLibsJoglCfg(final Class<?>[] classesFromJavaJars)

Loads and adds a JAR file's native library to the TempJarCache, calling JNILibLoaderBase#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
  • ..
addNativeJarLibsWithTempJarCacheback to summary
private static boolean addNativeJarLibsWithTempJarCache(final Class<?>[] classesFromJavaJars, final String singleJarMarker)
disableLoadingback to summary
public static void disableLoading()
enableLoadingback to summary
public static void enableLoading()
isLoadedback to summary
public static boolean isLoaded(final String libName)
loadLibraryback to summary
protected static synchronized boolean loadLibrary(final String libname, final boolean ignoreError, final ClassLoader cl)

Loads the library specified by libname, using the LoaderAction set by setLoadingAction(LoaderAction).
The implementation should ignore, if the library has been loaded already.

Parameters
libname:String

the library to load

ignoreError:boolean

if true, errors during loading the library should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library

Returns:boolean

true if library loaded successful

loadLibraryback to summary
protected static synchronized void loadLibrary(final String libname, final String[] preload, final boolean preloadIgnoreError, final ClassLoader cl)

Loads the library specified by libname, using the LoaderAction set by setLoadingAction(LoaderAction).
Optionally preloads the libraries specified by preload.
The implementation should ignore, if any library has been loaded already.

Parameters
libname:String

the library to load

preload:String[]

the libraries to load before loading the main library if not null

preloadIgnoreError:boolean

if true, errors during loading the preload-libraries should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library

loadLibraryInternalback to summary
private static void loadLibraryInternal(final String libraryName, final ClassLoader cl)
setLoadingActionback to summary
public static synchronized void setLoadingAction(final JNILibLoaderBase.LoaderAction action)
com.jogamp.common.jvm back to summary

private Class JNILibLoaderBase.DefaultAction

extends Object
implements LoaderAction
Class Inheritance
All Implemented Interfaces
com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
loadLibrary(final String
the library to load
libname
,
final boolean
if true, errors during loading the library should be ignored
ignoreError
,
final ClassLoader
optional ClassLoader, used to locate the library
cl
)

Implements com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Loads the library specified by libname.
public void
loadLibrary(final String
the library to load
libname
,
final String[]
the libraries to load before loading the main library if not null
preload
,
final boolean
if true, errors during loading the preload-libraries should be ignored
preloadIgnoreError
,
final ClassLoader
optional ClassLoader, used to locate the library
cl
)

Implements com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Loads the library specified by libname.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultActionback to summary
private DefaultAction()

Method Detail

loadLibraryback to summary
public boolean loadLibrary(final String libname, final boolean ignoreError, final ClassLoader cl)

Implements com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Doc from com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Loads the library specified by libname.
The implementation should ignore, if the library has been loaded already.

Parameters
libname:String

the library to load

ignoreError:boolean

if true, errors during loading the library should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library

Returns:boolean

true if library loaded successful

Annotations
@Override
loadLibraryback to summary
public void loadLibrary(final String libname, final String[] preload, final boolean preloadIgnoreError, final ClassLoader cl)

Implements com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Doc from com.jogamp.common.jvm.JNILibLoaderBase.LoaderAction.loadLibrary.

Loads the library specified by libname.
Optionally preloads the libraries specified by preload.
The implementation should ignore, if any library has been loaded already.

Parameters
libname:String

the library to load

preload:String[]

the libraries to load before loading the main library if not null

preloadIgnoreError:boolean

if true, errors during loading the preload-libraries should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library

Annotations
@Override
com.jogamp.common.jvm back to summary

public Interface JNILibLoaderBase.LoaderAction

Known Direct Implementers
com.jogamp.common.jvm.JNILibLoaderBase.DefaultAction

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if library loaded successful
loadLibrary
(String
the library to load
libname
,
boolean
if true, errors during loading the library should be ignored
ignoreError
,
ClassLoader
optional ClassLoader, used to locate the library
cl
)

Loads the library specified by libname.

public void
loadLibrary(String
the library to load
libname
,
String[]
the libraries to load before loading the main library if not null
preload
,
boolean
if true, errors during loading the preload-libraries should be ignored
preloadIgnoreError
,
ClassLoader
optional ClassLoader, used to locate the library
cl
)

Loads the library specified by libname.

Method Detail

loadLibraryback to summary
public boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl)

Loads the library specified by libname.
The implementation should ignore, if the library has been loaded already.

Parameters
libname:String

the library to load

ignoreError:boolean

if true, errors during loading the library should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library

Returns:boolean

true if library loaded successful

loadLibraryback to summary
public void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError, ClassLoader cl)

Loads the library specified by libname.
Optionally preloads the libraries specified by preload.
The implementation should ignore, if any library has been loaded already.

Parameters
libname:String

the library to load

preload:String[]

the libraries to load before loading the main library if not null

preloadIgnoreError:boolean

if true, errors during loading the preload-libraries should be ignored

cl:ClassLoader

optional ClassLoader, used to locate the library