diff options
author | Sven Gothel <[email protected]> | 2011-09-21 20:52:10 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-21 20:52:10 +0200 |
commit | def691b009132463f8ec8efabd0d72768235dcf5 (patch) | |
tree | 574ce12a6bd1ff12b93faaac70c36f3dc5256364 /src/java/com/jogamp/common/jvm | |
parent | 0e44b330403011558391c732a0b6240694ecb6a1 (diff) |
Unify JNI Library Loading into JNILibLoaderBase and use it for the gluegen-rt native lib as well
- removed redundance
- move proper JNLPAppletLauncher custom libloader code into JNILibLoaderBase
- prepares for new JAR temp cache ..
Diffstat (limited to 'src/java/com/jogamp/common/jvm')
-rw-r--r-- | src/java/com/jogamp/common/jvm/JNILibLoaderBase.java | 46 | ||||
-rw-r--r-- | src/java/com/jogamp/common/jvm/JVMUtil.java | 4 |
2 files changed, 30 insertions, 20 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java index 2ad0504..161f0c4 100644 --- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java +++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java @@ -106,7 +106,7 @@ public class JNILibLoaderBase { } } - private static final HashSet loaded = new HashSet(); + private static final HashSet<String> loaded = new HashSet<String>(); private static LoaderAction loaderAction = new DefaultAction(); public static boolean isLoaded(String libName) { @@ -145,30 +145,41 @@ public class JNILibLoaderBase { } } - private static final Class customLauncherClass; + // private static final Class<?> customLauncherClass; private static final Method customLoadLibraryMethod; // FIXME centralize logging static { - Class launcherClass = null; + final String sunAppletLauncherProperty = "sun.jnlp.applet.launcher"; + final String sunAppletLauncherClassName = "org.jdesktop.applet.util.JNLPAppletLauncher"; + final boolean usingJNLPAppletLauncher = Boolean.valueOf(System.getProperty(sunAppletLauncherProperty)).booleanValue(); + + Class<?> launcherClass = null; Method loadLibraryMethod = null; - if ( Debug.getBooleanProperty("sun.jnlp.applet.launcher", false, localACC) ) { + if (usingJNLPAppletLauncher) { try { - launcherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher"); - loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class }); - } catch (ClassNotFoundException ex) { - if(DEBUG) { - ex.printStackTrace(); - } - } catch (NoSuchMethodException ex) { - if(DEBUG) { - ex.printStackTrace(); - } - launcherClass = null; + launcherClass = Class.forName(sunAppletLauncherClassName); + } catch (ClassNotFoundException cnfe) { + // oops .. look like JNLPAppletLauncher doesn't exist, despite property + // this may happen if a previous applet was using JNLPAppletLauncher in the same JVM + System.err.println("JNILibLoaderBase: <"+sunAppletLauncherClassName+"> not found, despite enabled property <"+sunAppletLauncherProperty+">, JNLPAppletLauncher was probably used before"); + System.setProperty(sunAppletLauncherProperty, Boolean.FALSE.toString()); + } catch (LinkageError le) { + throw le; + } + if(null != launcherClass) { + try { + loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class }); + } catch (NoSuchMethodException ex) { + if(DEBUG) { + ex.printStackTrace(); + } + launcherClass = null; + } } } - + if(null==launcherClass) { String launcherClassName = Debug.getProperty("jnlp.launcher.class", false, localACC); if(null!=launcherClassName) { @@ -187,8 +198,7 @@ public class JNILibLoaderBase { } } } - - customLauncherClass = launcherClass; + // customLauncherClass = launcherClass; customLoadLibraryMethod = loadLibraryMethod; } diff --git a/src/java/com/jogamp/common/jvm/JVMUtil.java b/src/java/com/jogamp/common/jvm/JVMUtil.java index 8657ae8..9ad9baf 100644 --- a/src/java/com/jogamp/common/jvm/JVMUtil.java +++ b/src/java/com/jogamp/common/jvm/JVMUtil.java @@ -37,7 +37,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.NativeLibrary; import jogamp.common.Debug; -import com.jogamp.gluegen.runtime.NativeLibLoader; +import com.jogamp.gluegen.runtime.GlueGenJNILibLoader; /** * Currently this tool works around the Hotspot race condition bugs: @@ -54,7 +54,7 @@ public class JVMUtil { private static final boolean DEBUG = Debug.debug("JVMUtil"); static { - NativeLibLoader.loadGlueGenRT(); + GlueGenJNILibLoader.loadGlueGenRT(); ByteBuffer buffer = Buffers.newDirectByteBuffer(64); if( ! initialize(buffer) ) { |