diff options
author | Sven Gothel <[email protected]> | 2011-11-21 14:07:06 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-11-21 14:07:06 +0100 |
commit | 72ad7010704c2dbb96a0a850c2bee76a5c64989c (patch) | |
tree | e1bd1771683d414b0a4936bf7ebac90599779829 | |
parent | 12342c9e6122051fbdc91493c4d63515ad4613d1 (diff) |
Initialize JAWTUtil/JAWTJNILibLoader in static initialzier block, not leaving privileged block
3 files changed, 9 insertions, 4 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index b6c850098..c3b91ec50 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -208,7 +208,7 @@ public abstract class NativeWindowFactory { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { try { - jawtUtilClass = Class.forName(JAWTUtilClassName, false, NativeWindowFactory.class.getClassLoader()); + jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader()); jawtUtilInitMethod = jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null); jawtUtilInitMethod.setAccessible(true); jawtUtilGetJAWTToolkitMethod = jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{}); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java index 2c8538278..36834eb9e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java @@ -46,8 +46,8 @@ import java.awt.Toolkit; import java.security.AccessController; import java.security.PrivilegedAction; -public class JAWTJNILibLoader extends NWJNILibLoader { - public static void loadAWTImpl() { +public class JAWTJNILibLoader extends NWJNILibLoader { + static { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise @@ -73,4 +73,9 @@ public class JAWTJNILibLoader extends NWJNILibLoader { } }); } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index ddf453bab..45b55e46e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -109,7 +109,7 @@ public class JAWTUtil { } static { - JAWTJNILibLoader.loadAWTImpl(); + JAWTJNILibLoader.initSingleton(); JAWTJNILibLoader.loadNativeWindow("awt"); headlessMode = GraphicsEnvironment.isHeadless(); |