summaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-07-04 02:51:49 +0000
committerSven Gothel <[email protected]>2010-04-19 00:56:25 +0200
commit8c57934736fac7b3e268020e64910a984b24e8c6 (patch)
tree07f3792af7f992dc0964b6d6727fa39a3f2d05d7 /src/nativewindow
parentc9ffd9ba1a1fdc9934e517baf96c9f7959f0e5b2 (diff)
Push custom loadLibrary handling down to NativeWindow NativeLibLoaderBase; X11AWTGLXGraphicsConfigurationFactory: Encapsule whole block in lock/unlock to minimize context switch
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@2021 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java
index e1427d7..570cf1f 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java
@@ -70,7 +70,7 @@ public class NativeLibLoaderBase {
for (int i=0; i<preload.length; i++) {
if(!isLoaded(preload[i])) {
try {
- System.loadLibrary(preload[i]);
+ loadLibraryInternal(preload[i]);
addLoaded(preload[i]);
if(DEBUG) {
System.err.println("NativeLibLoaderBase preloaded "+preload[i]);
@@ -85,7 +85,7 @@ public class NativeLibLoaderBase {
}
}
}
- System.loadLibrary(libname);
+ loadLibraryInternal(libname);
addLoaded(libname);
if(DEBUG) {
System.err.println("NativeLibLoaderBase loaded "+libname);
@@ -135,4 +135,68 @@ public class NativeLibLoaderBase {
}
});
}
+
+
+ private static final Class customLauncherClass;
+ private static final Method customLoadLibraryMethod;
+
+ static {
+ Class launcherClass = null;
+ Method loadLibraryMethod = null;
+
+ if ( Debug.getBooleanProperty("sun.jnlp.applet.launcher", false) ) {
+ try {
+ launcherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher");
+ loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
+ } catch (Throwable t) {
+ if(DEBUG) {
+ t.printStackTrace();
+ }
+ launcherClass = null;
+ loadLibraryMethod = null;
+ }
+ }
+
+ if(null==launcherClass) {
+ String launcherClassName = Debug.getProperty("jnlp.launcher.class", false);
+ if(null!=launcherClassName) {
+ try {
+ launcherClass = Class.forName(launcherClassName);
+ loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
+ } catch (Throwable t) {
+ if(DEBUG) {
+ t.printStackTrace();
+ }
+ launcherClass = null;
+ loadLibraryMethod = null;
+ }
+ }
+ }
+ customLauncherClass = launcherClass;
+ customLoadLibraryMethod = loadLibraryMethod;
+ }
+
+ private static void loadLibraryInternal(String libraryName) {
+ // Note: special-casing JAWT which is built in to the JDK
+ if (null!=customLoadLibraryMethod && !libraryName.equals("jawt")) {
+ try {
+ customLoadLibraryMethod.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);
+ }
+ } else {
+ // System.out.println("sun.boot.library.path=" + Debug.getProperty("sun.boot.library.path", false));
+ System.loadLibrary(libraryName);
+ }
+ }
}