jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Static Public Member Functions | List of all members
org.jau.pkg.JNIJarLibrary Class Reference

Static JNI Native Libraries handler including functionality for native JAR files using JarUtil and TempJarCache. More...

Inheritance diagram for org.jau.pkg.JNIJarLibrary:
Collaboration diagram for org.jau.pkg.JNIJarLibrary:

Static Public Member Functions

static boolean addNativeJarLibs (final Class<?>[] classesFromJavaJars, final String singleJarMarker)
 Loads and adds a JAR file's native library to the TempJarCache. More...
 
- Static Public Member Functions inherited from org.jau.sys.JNILibrary
static final String getSystemEnvLibraryPathVarname ()
 Returns the system's environment variable name used for the dynamic linker to resolve library locations, e.g. More...
 
static final List< String > getSystemEnvLibraryPaths ()
 Returns a list of system paths, from the getSystemEnvLibraryPathVarname() variable. More...
 
static synchronized boolean isLoaded (final String libName)
 
static synchronized boolean loadLibrary (final String libname, final boolean ignoreError, final ClassLoader cl) throws SecurityException, UnsatisfiedLinkError
 Loads the library specified by libname. More...
 
static synchronized void loadLibrary (final String libname, final String[] preload, final boolean preloadIgnoreError, final ClassLoader cl) throws SecurityException, UnsatisfiedLinkError
 Loads the library specified by libname. More...
 
static final String findLibrary (final String libName, final ClassLoader loader)
 
static final String isValidNativeLibraryName (final String libName, final boolean isLowerCaseAlready)
 Comparison of prefix and suffix of the given libName's basename is performed case insensitive
More...
 
static final List< String > enumerateLibraryPaths (final String libName, final boolean searchSystemPath, final boolean searchSystemPathFirst, final ClassLoader loader)
 Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system using the system path. More...
 
static final List< String > enumerateLibraryPaths (final String windowsLibName, final String unixLibName, final String macOSXLibName, final boolean searchSystemPath, final boolean searchSystemPathFirst, final ClassLoader loader)
 Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system using the system path. More...
 

Additional Inherited Members

- Static Public Attributes inherited from org.jau.sys.JNILibrary
static final boolean DEBUG
 
- Static Protected Attributes inherited from org.jau.sys.JNILibrary
static final boolean PERF
 
static final Object perfSync = new Object()
 
static long perfTotal = 0
 
static long perfCount = 0
 

Detailed Description

Static JNI Native Libraries handler including functionality for native JAR files using JarUtil and TempJarCache.

Definition at line 42 of file JNIJarLibrary.java.

Member Function Documentation

◆ addNativeJarLibs()

static boolean org.jau.pkg.JNIJarLibrary.addNativeJarLibs ( final Class<?>[]  classesFromJavaJars,
final String  singleJarMarker 
)
static

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


The native library JAR file's URI is derived as follows:

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 };
  JNIJarLibrary.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<?>[] { JOCLJNILibrary.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<?>[] { NWJNILibrary.class, GLProfile.class, null };
  if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) {
      classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl);
  }
  JNIJarLibrary.addNativeJarLibs(classesFromJavaJars, "-all");
Parameters
classesFromJavaJarsFor each given Class, load the native library JAR.
singleJarMarkerOptional string marker like "-all" to identify the single 'all-in-one' JAR file after which processing of the class array shall stop.
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

Definition at line 252 of file JNIJarLibrary.java.

Here is the call graph for this function:

The documentation for this class was generated from the following file: