aboutsummaryrefslogtreecommitdiffstats
path: root/make/config/nativewindow/jawt-CustomJavaCode.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-03-17 20:41:40 +0000
committerKenneth Russel <[email protected]>2009-03-17 20:41:40 +0000
commit9a44770462cc3e10af1eee66a75e708bd540fce9 (patch)
tree18d907e45445e4121928d4b1a592428f17ca065f /make/config/nativewindow/jawt-CustomJavaCode.java
parent3ad5bf195cec28d7578ee417f9425a871ce7ef57 (diff)
Continue moving javax.media.nwi -> javax.media.nativewindow
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1881 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/config/nativewindow/jawt-CustomJavaCode.java')
-rwxr-xr-xmake/config/nativewindow/jawt-CustomJavaCode.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
new file mode 100755
index 000000000..f1ef91075
--- /dev/null
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -0,0 +1,27 @@
+private static volatile JAWT jawt;
+
+/** Helper routine for all users to call to access the JAWT. */
+public static JAWT getJAWT() {
+ if (jawt == null) {
+ synchronized (JAWT.class) {
+ if (jawt == null) {
+ JAWTNativeLibLoader.loadAWTImpl();
+ // 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.
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ JAWT j = JAWT.create();
+ j.version(JAWTFactory.JAWT_VERSION_1_4);
+ if (!JAWTFactory.JAWT_GetAWT(j)) {
+ throw new RuntimeException("Unable to initialize JAWT");
+ }
+ jawt = j;
+ return null;
+ }
+ });
+ }
+ }
+ }
+ return jawt;
+}