This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: more JNI fixes


I'm checking this in.

It fixes a problem noted by Marcus Daniels.
It also generalizes an earlier fix: it turns out that we sometimes
return jthrowable, jstring, jarray, etc -- each of which needs to be
made into a local reference.  So I changed how wrap_value is
specialized to solve this problem in general.

This is going on the trunk and branch.

2001-04-06  Tom Tromey  <tromey@redhat.com>

	* jni.cc (wrap_value<jobject>, wrap_value<jclass>): Removed.
	(wrap_value<T*>): New specialization.
	(_Jv_JNI_PopLocalFrame): Update env->locals.

Tom

Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.36.4.4
diff -u -r1.36.4.4 jni.cc
--- jni.cc	2001/04/02 22:51:54	1.36.4.4
+++ jni.cc	2001/04/06 17:35:47
@@ -335,6 +335,9 @@
       rf = n;
     }
 
+  // Update the local frame information.
+  env->locals = rf;
+
   return result == NULL ? NULL : _Jv_JNI_NewLocalRef (env, result);
 }
 
@@ -368,21 +371,16 @@
 {
   return value;
 }
-
-template<>
-static jobject
-wrap_value (JNIEnv *env, jobject value)
-{
-  return value == NULL ? value : _Jv_JNI_NewLocalRef (env, value);
-}
 
-template<>
-static jclass
-wrap_value (JNIEnv *env, jclass value)
+// This specialization is used for jobject, jclass, jstring, jarray,
+// etc.
+template<typename T>
+static T *
+wrap_value (JNIEnv *env, T *value)
 {
   return (value == NULL
 	  ? value
-	  : (jclass) _Jv_JNI_NewLocalRef (env, (jobject) value));
+	  : (T *) _Jv_JNI_NewLocalRef (env, (jobject) value));
 }
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]