aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com/sun
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-07-04 02:51:49 +0000
committerSven Gothel <[email protected]>2009-07-04 02:51:49 +0000
commit918b42027e024f3b7973463a6391db8c11d5d778 (patch)
tree1e24caa96ac94d450595e1a5a58bd7eeccb0b2f7 /src/nativewindow/classes/com/sun
parent7dcb2b468ee7f3453fe69642e42cf4c2a21a0989 (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/classes/com/sun')
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java68
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java2
2 files changed, 67 insertions, 3 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java
index e1427d7be..570cf1f9d 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);
+ }
+ }
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
index 20e8cf966..af93b8c31 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
@@ -46,7 +46,7 @@ public class JAWTUtil {
static {
JAWTNativeLibLoader.loadAWTImpl();
- NativeLibLoaderBase.loadNativeWindow("awt");
+ JAWTNativeLibLoader.loadNativeWindow("awt");
lockedStack = null;
headlessMode = GraphicsEnvironment.isHeadless();