Hi,

On Sun, 2005-09-11 at 13:47 -0500, Archie Cobbs wrote:
> David Lichteblau wrote:
> > jcl.c currently tries to turn a local reference into a global one after
> > having deleted the local reference.
> >       (*env)->DeleteLocalRef(env, rawDataClass);
> >       rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
> > Is my interpretation right that this is not allowed by the JNI spec?
> 
> Yes.. patch looks OK to me too.

Same here. Amazing this wasn't noticed before by some other runtime.
Committed as follows:

2005-09-17  Mark Wielaard  <[EMAIL PROTECTED]>

        Reported by David Lichteblau <[EMAIL PROTECTED]>
        * native/jni/classpath/jcl.c (JCL_NewRawDataObject): Create
        NewGlobalRef before calling DeleteLocalRef.

Thanks,

Mark
Index: native/jni/classpath/jcl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/jcl.c,v
retrieving revision 1.17
diff -u -r1.17 jcl.c
--- native/jni/classpath/jcl.c	14 Sep 2005 14:40:05 -0000	1.17
+++ native/jni/classpath/jcl.c	17 Sep 2005 21:38:54 -0000
@@ -193,6 +193,7 @@
 {
   if (rawDataClass == NULL)
     {
+      jclass tmp;
 #if SIZEOF_VOID_P == 8
       rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64");
       if (rawDataClass == NULL)
@@ -243,14 +244,15 @@
 	}
 
 #endif
-      (*env)->DeleteLocalRef(env, rawDataClass);
-      rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
-      if (rawDataClass == NULL)
+      tmp = (*env)->NewGlobalRef (env, rawDataClass);
+      if (tmp == NULL)
 	{
 	  JCL_ThrowException (env, "java/lang/InternalError",
 			      "unable to create an internal global ref");
 	  return NULL;
 	}
+      (*env)->DeleteLocalRef(env, rawDataClass);
+      rawDataClass = tmp;
     }
 
 #if SIZEOF_VOID_P == 8

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to