From 9723c1fc5710051fd52f29c8b960379cc02ae991 Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Sun, 3 Feb 2008 06:57:11 +0000
Subject: Fixed Issue 341: JNI Global Reference in native code prevents clean
 applet termination

Simplified the native code in JAWT_DrawingSurfaceInfo.c to only
fabricate the direct ByteBuffer wrapping the JAWT "platformInfo"
struct, moving the construction of the wrapping JAWT_PlatformInfo up
to Java.

Verified fix with reloading of JOGL applets via the new JNLP applet
launching support in the new Java Plug-In.


git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1512 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 make/jawt-DrawingSurfaceInfo-CustomJavaCode.java | 38 ++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 make/jawt-DrawingSurfaceInfo-CustomJavaCode.java

(limited to 'make/jawt-DrawingSurfaceInfo-CustomJavaCode.java')

diff --git a/make/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/jawt-DrawingSurfaceInfo-CustomJavaCode.java
new file mode 100755
index 000000000..2e9bd37b6
--- /dev/null
+++ b/make/jawt-DrawingSurfaceInfo-CustomJavaCode.java
@@ -0,0 +1,38 @@
+public JAWT_PlatformInfo platformInfo() {
+  return newPlatformInfo(platformInfo0(getBuffer()));
+}
+
+private native ByteBuffer platformInfo0(Buffer jthis0);
+
+private static java.lang.reflect.Method platformInfoFactoryMethod;
+
+private static JAWT_PlatformInfo newPlatformInfo(ByteBuffer buf) {
+  if (platformInfoFactoryMethod == null) {
+    String osName = (String) AccessController.doPrivileged(new PrivilegedAction() {
+        public Object run() {
+          return System.getProperty("os.name").toLowerCase();
+        }
+      });
+    try {
+      Class factoryClass;
+      if (osName.startsWith("wind")) {
+        factoryClass = Class.forName("com.sun.opengl.impl.windows.JAWT_Win32DrawingSurfaceInfo");
+      } else if (osName.startsWith("mac os x")) {
+        factoryClass = Class.forName("com.sun.opengl.impl.macosx.JAWT_MacOSXDrawingSurfaceInfo");
+      } else {
+        // Assume Linux, Solaris, etc. Should probably test for these explicitly.
+        factoryClass = Class.forName("com.sun.opengl.impl.x11.JAWT_X11DrawingSurfaceInfo");
+      }
+      platformInfoFactoryMethod = factoryClass.getMethod("create",
+                                                         new Class[] { ByteBuffer.class });
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+  try {
+    return (JAWT_PlatformInfo)
+      platformInfoFactoryMethod.invoke(null, new Object[] { buf });
+  } catch (Exception e) {
+    throw new RuntimeException(e);
+  }
+}
-- 
cgit v1.2.3