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 | |
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')
6 files changed, 38 insertions, 28 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) ) { diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java index 1d99767..90e31f8 100644 --- a/src/java/com/jogamp/common/nio/AbstractBuffer.java +++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java @@ -32,7 +32,7 @@ package com.jogamp.common.nio; import com.jogamp.common.os.*; -import com.jogamp.gluegen.runtime.NativeLibLoader; +import com.jogamp.gluegen.runtime.GlueGenJNILibLoader; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -49,7 +49,7 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native protected int position; static { - NativeLibLoader.loadGlueGenRT(); + GlueGenJNILibLoader.loadGlueGenRT(); } /** diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java index 27a0bc6..d2691d9 100644 --- a/src/java/com/jogamp/common/nio/PointerBuffer.java +++ b/src/java/com/jogamp/common/nio/PointerBuffer.java @@ -39,7 +39,7 @@ import java.nio.LongBuffer; import com.jogamp.common.os.NativeLibrary; import com.jogamp.common.os.Platform; import com.jogamp.common.util.LongObjectHashMap; -import com.jogamp.gluegen.runtime.NativeLibLoader; +import com.jogamp.gluegen.runtime.GlueGenJNILibLoader; /** * Hardware independent container for native pointer arrays. @@ -55,7 +55,7 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { protected LongObjectHashMap dataMap = null; static { - NativeLibLoader.loadGlueGenRT(); + GlueGenJNILibLoader.loadGlueGenRT(); } /** no backup array, use for direct usage only */ diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index 23e1714..b7e0739 100755 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -250,7 +250,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { boolean ignoreError = true; boolean res; try { - res = GlueJNILibLoaderBase.loadLibrary(libName, ignoreError); + res = GlueJNILibLoader.loadLibrary(libName, ignoreError); if(DEBUG && !res) { System.err.println("Info: Could not load JNI/Glue library: "+libName); } @@ -339,7 +339,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } /** Inherit access */ - static class GlueJNILibLoaderBase extends JNILibLoaderBase { + static class GlueJNILibLoader extends JNILibLoaderBase { protected static synchronized boolean loadLibrary(String libname, boolean ignoreError) { return JNILibLoaderBase.loadLibrary(libname, ignoreError); } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index beee639..c8dfdf1 100755 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -41,7 +41,7 @@ package com.jogamp.common.os; import com.jogamp.common.util.IOUtil; -import com.jogamp.gluegen.runtime.NativeLibLoader; +import com.jogamp.gluegen.runtime.GlueGenJNILibLoader; import jogamp.common.Debug; import jogamp.common.os.MacOSXDynamicLinkerImpl; import jogamp.common.os.UnixDynamicLinkerImpl; @@ -175,7 +175,7 @@ public class NativeLibrary implements DynamicLookupHelper { if (DEBUG) { System.err.println("Trying to load " + path); } - NativeLibLoader.loadGlueGenRT(); + GlueGenJNILibLoader.loadGlueGenRT(); long res; if(global) { res = dynLink.openLibraryGlobal(path, DEBUG); |