summaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/NativeLibLoader.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-11-09 20:11:30 +0000
committerKenneth Russel <[email protected]>2005-11-09 20:11:30 +0000
commitdba4677caf231ac26c70518a3e82651b0e01c8f2 (patch)
tree53b494a55ff1c4a00c6d2bd1dbb3e4b7e66b8b5e /src/classes/com/sun/opengl/impl/NativeLibLoader.java
parent23e6684c5ae7047f39620e861b607db2f761799d (diff)
Refactored JOGL's use of the JAWT to enable it to be more lazily
loaded. Separated out AWT-specific native code into a new jogl_awt native library on all platforms. Added a static helper method to the JAWT class to fetch the JAWT which is now called by all users. Added a new NativeLibLoader entry point to load the native code for the AWT implementation. Renamed the X11 platform's "lockAWT" and "unlockAWT" methods to "lockToolkit" and "unlockToolkit", respectively. In order to change this behavior only two methods in X11GLDrawableFactory need to be overridden. (During the writing of this checkin comment it was noted that these methods are currently static, but that will be fixed in a subsequent checkin.) Added the new jogl_awt native library to the the "dist" target's error checking code. Tested on Windows; more testing, including build testing, is needed on other platforms. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@429 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/NativeLibLoader.java')
-rw-r--r--src/classes/com/sun/opengl/impl/NativeLibLoader.java76
1 files changed, 46 insertions, 30 deletions
diff --git a/src/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/classes/com/sun/opengl/impl/NativeLibLoader.java
index 6d4815cd7..1a3d5c277 100644
--- a/src/classes/com/sun/opengl/impl/NativeLibLoader.java
+++ b/src/classes/com/sun/opengl/impl/NativeLibLoader.java
@@ -44,7 +44,6 @@ import java.security.*;
public class NativeLibLoader {
private static volatile boolean doLoading = true;
- private static volatile boolean doneLoading = false;
public static void disableLoading() {
doLoading = false;
@@ -54,38 +53,55 @@ public class NativeLibLoader {
doLoading = true;
}
- public static synchronized void load() {
- if (doLoading && !doneLoading) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
- if (!isOSX) {
- try {
- // On X11 systems, toolkit must be loaded before
- // trying to resolve JAWT in order for libmawt.so to
- // be found properly
- Toolkit.getDefaultToolkit();
- System.loadLibrary("jawt");
- } catch (UnsatisfiedLinkError e) {
- // Accessibility technologies load JAWT themselves; safe to continue
- // as long as JAWT is loaded by any loader
- if (e.getMessage().indexOf("already loaded") == -1) {
- throw e;
- }
+ private static volatile boolean loadedCore = false;
+ private static volatile boolean loadedAWTImpl = false;
+
+ public static void loadCore() {
+ if (doLoading && !loadedCore) {
+ synchronized (NativeLibLoader.class) {
+ if (!loadedCore) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ System.loadLibrary("jogl");
+ return null;
}
- }
- System.loadLibrary("jogl");
+ });
+ loadedCore = true;
+ }
+ }
+ }
+ }
- // Workaround for 4845371.
- // Make sure the first reference to the JNI GetDirectBufferAddress is done
- // from a privileged context so the VM's internal class lookups will succeed.
- JAWT jawt = JAWT.create();
- JAWTFactory.JAWT_GetAWT(jawt);
+ public static void loadAWTImpl() {
+ if (doLoading && !loadedAWTImpl) {
+ synchronized (NativeLibLoader.class) {
+ if (!loadedAWTImpl) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
+ if (!isOSX) {
+ // Must pre-load JAWT on all non-Mac platforms to
+ // ensure references from jogl_awt shared object
+ // will succeed since JAWT shared object isn't in
+ // default library path
+ try {
+ System.loadLibrary("jawt");
+ } catch (UnsatisfiedLinkError e) {
+ // Accessibility technologies load JAWT themselves; safe to continue
+ // as long as JAWT is loaded by any loader
+ if (e.getMessage().indexOf("already loaded") == -1) {
+ throw e;
+ }
+ }
+ }
+ System.loadLibrary("jogl_awt");
- return null;
- }
- });
- doneLoading = true;
+ return null;
+ }
+ });
+ loadedAWTImpl = true;
+ }
+ }
}
}
}