summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-02-12 19:45:46 +0000
committerKenneth Russel <[email protected]>2005-02-12 19:45:46 +0000
commit880c498e4b360fa2f51feb606e621badf902ab83 (patch)
tree344bb12730e684513d1e247cb16086a838a9c09c
parentf6929758c3a712f6548955482fa366ccdd5b9dd2 (diff)
Fixed Issue 110: NativeLibLoader should have a flag for loading the library
Applied suggested patch from submitter. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@225 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r--src/net/java/games/jogl/impl/NativeLibLoader.java61
1 files changed, 36 insertions, 25 deletions
diff --git a/src/net/java/games/jogl/impl/NativeLibLoader.java b/src/net/java/games/jogl/impl/NativeLibLoader.java
index cf2b06939..0c2420955 100644
--- a/src/net/java/games/jogl/impl/NativeLibLoader.java
+++ b/src/net/java/games/jogl/impl/NativeLibLoader.java
@@ -42,34 +42,45 @@ package net.java.games.jogl.impl;
import java.security.*;
public class NativeLibLoader {
- static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
- if (!isOSX) {
- 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");
+ private static volatile boolean doLoading = true;
+ private static volatile boolean doneLoading = false;
- // 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 = new JAWT();
- JAWTFactory.JAWT_GetAWT(jawt);
+ public static void disableLoading() {
+ doLoading = false;
+ }
- return null;
- }
- });
+ public static void enableLoading() {
+ doLoading = true;
}
- public static void load() {
+ 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 {
+ 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");
+
+ // 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 = new JAWT();
+ JAWTFactory.JAWT_GetAWT(jawt);
+
+ return null;
+ }
+ });
+ doneLoading = true;
+ }
}
}