summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/jvm
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-01 16:18:34 +0100
committerSven Gothel <[email protected]>2011-12-01 16:18:34 +0100
commit7e6cf46ed2e0e9772f79e06437596056efa8c682 (patch)
tree35e1155262be9e188bdbb7d64f24642d9914e6d3 /src/java/com/jogamp/common/jvm
parentae8f6b7ed095abe2ff2284211b40ba8720e2446f (diff)
Refine TempJarCache/JNILibLoaderBase ; Add TempFileCache destroy() for instance.
JNILibLoaderBase's 'addNativeJarLibs(Class<?> classFromJavaJar, String allNativeJarBaseName, String[] atomicNativeJarBaseNames)' now just attempts to load the 'all' variant, and will continue w/ atomics if not successful (ie not available). It skips the validation of a 'allJavaJarPrefix', ie validating the 'classFromJavaJar holding JAR file, which allows GLUEGEN/JOGL classes to be contained in JAR files other than the original.
Diffstat (limited to 'src/java/com/jogamp/common/jvm')
-rw-r--r--src/java/com/jogamp/common/jvm/JNILibLoaderBase.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
index 31e777a..c0addfc 100644
--- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
+++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
@@ -144,7 +144,7 @@ public class JNILibLoaderBase {
*
* @param classFromJavaJar GLProfile
* @param nativeJarBaseName jogl-all
- * @return
+ * @return true if the native JAR file loaded successful or were loaded already, false in case of an error
*/
public static final boolean addNativeJarLibs(Class<?> classFromJavaJar, String nativeJarBaseName) {
if(TempJarCache.isInitialized()) {
@@ -163,35 +163,42 @@ public class JNILibLoaderBase {
if(DEBUG) {
System.err.println("JNILibLoaderBase: addNativeJarLibs: "+nativeJarBaseName+": nativeJar "+nativeJar.getName());
}
- return TempJarCache.addNativeLibs(classFromJavaJar, nativeJar);
+ TempJarCache.addNativeLibs(classFromJavaJar, nativeJar);
+ return true;
} catch (IOException ioe) {
ioe.printStackTrace();
+ } catch (Exception e0) {
+ e0.printStackTrace();
}
}
return false;
}
/**
- * @param classFromJavaJar GLProfile
- * @param allJavaJarPrefix "jogl.all"
- * @param allNativeJarBaseName "jogl-all"
- * @param atomicNativeJarBaseNames [ "nativewindow", "jogl", "newt" ]
+ * @param classFromJavaJar A class file to determine the base URL of the native JAR files, eg.: GLProfile.class
+ * @param allNativeJarBaseName Attempt to use the 'all' native JAR variant first, if exists. Eg. "jogl-all"
+ * @param atomicNativeJarBaseNames Fallback to use all the atomic native JAR files, eg. [ "nativewindow", "jogl", "newt" ]
+ * @return true if either the 'all' native JAR or all of the atomic native JARs loaded successful or were loaded already,
+ * false in case of an error
*/
- public static void addNativeJarLibs(Class<?> classFromJavaJar, String allJavaJarPrefix, String allNativeJarBaseName, String[] atomicNativeJarBaseNames) {
+ public static boolean addNativeJarLibs(Class<?> classFromJavaJar, String allNativeJarBaseName, String[] atomicNativeJarBaseNames) {
+ boolean res = false;
if(TempJarCache.isInitialized()) {
final ClassLoader cl = classFromJavaJar.getClassLoader();
try {
final String jarName = JarUtil.getJarBasename(classFromJavaJar.getName(), cl);
if(jarName!=null) {
- if( null != allJavaJarPrefix && jarName.startsWith(allJavaJarPrefix) ) {
- // all-in-one variant
- JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, allNativeJarBaseName);
- } else if(null != atomicNativeJarBaseNames) {
+ if(!res && null != allNativeJarBaseName) {
+ // all-in-one variant 1st
+ res = JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, allNativeJarBaseName);
+ }
+ if(!res && null != atomicNativeJarBaseNames) {
// atomic variant
- for(int i=0; i<atomicNativeJarBaseNames.length; i++) {
+ res = true;
+ for(int i=0; res && i<atomicNativeJarBaseNames.length; i++) {
final String atomicNativeJarBaseName = atomicNativeJarBaseNames[i];
if(null != atomicNativeJarBaseName && atomicNativeJarBaseName.length()>0) {
- JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, atomicNativeJarBaseName);
+ res = JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, atomicNativeJarBaseName);
}
}
}
@@ -200,6 +207,7 @@ public class JNILibLoaderBase {
ioe.printStackTrace();
}
}
+ return res;
}
protected static synchronized boolean loadLibrary(String libname, boolean ignoreError) {