diff options
Diffstat (limited to 'src/nativewindow/classes/com')
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java | 68 | ||||
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java | 2 |
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(); |