aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-23 13:17:36 +0200
committerSven Gothel <[email protected]>2011-09-23 13:17:36 +0200
commit9da5bc1fe999caa924bd8dceafeff93ddf9d16a0 (patch)
tree54a0206d47b03d1d914bb55707b52b2cabd829b5 /src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
parent675ea2c9ee6308d439b2429d0863a634ba673eff (diff)
TempJarCache/JNILibLoaderBase: Validate the to be loader JarFile's Certificates if caller has any. Add Convenient JNILibLoaderBase.addNativeJarLibs(..) method.
Diffstat (limited to 'src/java/com/jogamp/common/jvm/JNILibLoaderBase.java')
-rw-r--r--src/java/com/jogamp/common/jvm/JNILibLoaderBase.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
index 44cbd14..bb0860a 100644
--- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
+++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
@@ -39,12 +39,17 @@
package com.jogamp.common.jvm;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.URL;
import java.security.AccessController;
import java.security.AccessControlContext;
import java.util.HashSet;
+import java.util.jar.JarFile;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.JarUtil;
import com.jogamp.common.util.cache.TempJarCache;
import jogamp.common.Debug;
@@ -135,6 +140,31 @@ public class JNILibLoaderBase {
loaderAction = action;
}
+ public static final boolean addNativeJarLibs(Class<?> classFromJavaJar, String nativeJarBaseName) {
+ if(TempJarCache.isInitialized()) {
+ final String nativeJarName = nativeJarBaseName+"-natives-"+Platform.getOSAndArch()+".jar";
+ final ClassLoader cl = classFromJavaJar.getClassLoader();
+ try {
+ URL jarUrlRoot = JarUtil.getJarURLDirname( JarUtil.getJarURL( classFromJavaJar.getName(), cl ) );
+ if(DEBUG) {
+ System.err.println("addNativeJarLibs: "+nativeJarBaseName+": url-root "+jarUrlRoot);
+ }
+ URL nativeJarURL = JarUtil.getJarURL(jarUrlRoot, nativeJarName);
+ if(DEBUG) {
+ System.err.println("addNativeJarLibs: "+nativeJarBaseName+": nativeJarURL "+nativeJarURL);
+ }
+ JarFile nativeJar = JarUtil.getJarFile(nativeJarURL, cl);
+ if(DEBUG) {
+ System.err.println("addNativeJarLibs: "+nativeJarBaseName+": nativeJar "+nativeJar.getName());
+ }
+ return TempJarCache.addNativeLibs(classFromJavaJar, nativeJar);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+ return false;
+ }
+
protected static synchronized boolean loadLibrary(String libname, boolean ignoreError) {
if (loaderAction != null) {
return loaderAction.loadLibrary(libname, ignoreError);