summaryrefslogtreecommitdiffstats
path: root/src/native/jogl
diff options
context:
space:
mode:
authorKenneth Russel <kbrussel@alum.mit.edu>2008-02-03 06:57:11 +0000
committerKenneth Russel <kbrussel@alum.mit.edu>2008-02-03 06:57:11 +0000
commit9723c1fc5710051fd52f29c8b960379cc02ae991 (patch)
tree820613c6f712ce3d99306cde6bcc1737bd47f1b4 /src/native/jogl
parent77a06914560fbdd09e7adb19d30be4cf359269a7 (diff)
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
Diffstat (limited to 'src/native/jogl')
-rw-r--r--src/native/jogl/JAWT_DrawingSurfaceInfo.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/src/native/jogl/JAWT_DrawingSurfaceInfo.c b/src/native/jogl/JAWT_DrawingSurfaceInfo.c
index 2bbfc7932..d419f5767 100644
--- a/src/native/jogl/JAWT_DrawingSurfaceInfo.c
+++ b/src/native/jogl/JAWT_DrawingSurfaceInfo.c
@@ -41,26 +41,17 @@
#ifdef WIN32
#define PLATFORM_DSI_SIZE sizeof(JAWT_Win32DrawingSurfaceInfo)
- static const char* platformDSIClassName = "com/sun/opengl/impl/windows/JAWT_Win32DrawingSurfaceInfo";
#elif defined(linux) || defined(__sun) || defined(__FreeBSD__) || defined(_HPUX)
#define PLATFORM_DSI_SIZE sizeof(JAWT_X11DrawingSurfaceInfo)
- static const char* platformDSIClassName = "com/sun/opengl/impl/x11/JAWT_X11DrawingSurfaceInfo";
#elif defined(macosx)
#define PLATFORM_DSI_SIZE sizeof(JAWT_MacOSXDrawingSurfaceInfo)
- static const char* platformDSIClassName = "com/sun/opengl/impl/macosx/JAWT_MacOSXDrawingSurfaceInfo";
#else
ERROR: port JAWT_DrawingSurfaceInfo.c to your platform
#endif
-static jclass platformDSIClass = NULL;
-static jmethodID factoryMethod = NULL;
-
JNIEXPORT jobject JNICALL
Java_com_sun_opengl_impl_JAWT_1DrawingSurfaceInfo_platformInfo0(JNIEnv* env, jobject unused, jobject jthis0) {
JAWT_DrawingSurfaceInfo* dsi;
- jobject dirbuf;
- jclass clazz;
- char sig[512];
dsi = (*env)->GetDirectBufferAddress(env, jthis0);
if (dsi == NULL) {
(*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"),
@@ -70,25 +61,5 @@ Java_com_sun_opengl_impl_JAWT_1DrawingSurfaceInfo_platformInfo0(JNIEnv* env, job
if (dsi->platformInfo == NULL) {
return NULL;
}
- dirbuf = (*env)->NewDirectByteBuffer(env, dsi->platformInfo, PLATFORM_DSI_SIZE);
- if (dirbuf == NULL) {
- return NULL;
- }
- if (platformDSIClass == NULL) {
- /* Note: possible race condition here but we will only leak a few
- global JNI handles at worst */
- clazz = (*env)->FindClass(env, platformDSIClassName);
- if (clazz == NULL) {
- return NULL;
- }
- clazz = (jclass) (*env)->NewGlobalRef(env, clazz);
- sprintf(sig, "(Ljava/nio/ByteBuffer;)L%s;", platformDSIClassName);
- factoryMethod = (*env)->GetStaticMethodID(env, clazz, "create", sig);
- if (factoryMethod == NULL) {
- (*env)->DeleteGlobalRef(env, clazz);
- return NULL;
- }
- platformDSIClass = clazz;
- }
- return (*env)->CallStaticObjectMethod(env, platformDSIClass, factoryMethod, dirbuf);
+ return (*env)->NewDirectByteBuffer(env, dsi->platformInfo, PLATFORM_DSI_SIZE);
}