summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-16 02:41:52 +0200
committerSven Gothel <[email protected]>2011-09-16 02:41:52 +0200
commit0711792f00e462e340e0d3731dfe71b0e8ec6022 (patch)
tree21b6d4f82d4f3a34cd50db45f1744f7d30ee16c2
parent0466210ac77e5c19248be1cc5c5b7c2a481ca031 (diff)
NativeLibLoader: Handle case where prev. Applet used JNLPAppletLauncher, setting it's magic property. Subsequent Applets may not use JNLPAppletLauncher, but property is still set.v2.0-rc3
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/NativeLibLoader.java54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/NativeLibLoader.java b/src/java/com/jogamp/gluegen/runtime/NativeLibLoader.java
index 94ff5d6..4e27c66 100755
--- a/src/java/com/jogamp/gluegen/runtime/NativeLibLoader.java
+++ b/src/java/com/jogamp/gluegen/runtime/NativeLibLoader.java
@@ -65,7 +65,7 @@ public class NativeLibLoader {
synchronized (NativeLibLoader.class) {
if (!didLoading && loadingEnabled) {
didLoading = true;
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
loadLibraryInternal("gluegen-rt");
return null;
@@ -77,29 +77,43 @@ public class NativeLibLoader {
}
private static void loadLibraryInternal(String libraryName) {
- String sunAppletLauncher = System.getProperty("sun.jnlp.applet.launcher");
- boolean usingJNLPAppletLauncher = Boolean.valueOf(sunAppletLauncher).booleanValue();
+ final String sunAppletLauncherProperty = "sun.jnlp.applet.launcher";
+ final String sunAppletLauncherClassName = "org.jdesktop.applet.util.JNLPAppletLauncher";
+ final boolean usingJNLPAppletLauncher = Boolean.valueOf(System.getProperty(sunAppletLauncherProperty)).booleanValue();
if (usingJNLPAppletLauncher) {
+ Class<?> jnlpAppletLauncherClass = null;
try {
- Class jnlpAppletLauncherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher");
- Method jnlpLoadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
- jnlpLoadLibraryMethod.invoke(null, new Object[] { libraryName });
- } catch (Exception e) {
- Throwable t = e;
- if (t instanceof InvocationTargetException) {
- t = ((InvocationTargetException) t).getTargetException();
- }
- if (t instanceof Error)
- throw (Error) t;
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary()
- throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e);
+ jnlpAppletLauncherClass = 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("NativeLibLoader: <"+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 != jnlpAppletLauncherClass) {
+ try {
+ Method jnlpLoadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
+ jnlpLoadLibraryMethod.invoke(null, new Object[] { libraryName });
+ return; // done
+ } catch (Exception e) {
+ Throwable t = e;
+ if (t instanceof InvocationTargetException) {
+ t = ((InvocationTargetException) t).getTargetException();
+ }
+ if (t instanceof Error) {
+ throw (Error) t;
+ }
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ }
+ // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary()
+ throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e);
+ }
}
- } else {
- System.loadLibrary(libraryName);
}
+ System.loadLibrary(libraryName);
}
}