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]
Other format: [Raw text]

Patch: comments please: JNI weak references


This patch adds support for the last two missing JNI functions, both
of which relate to weak global references.

It is a fairly large, somewhat ugly patch, and I thought I would ask
for comments before checking it in.

Basically a JNI weak reference can be used anywhere a JNI global or
local reference can be used.  In our JNI implementation we use the
object itself when handing the user a reference.  But for a weak
reference I think this won't work.

So in this patch we wrap every JNI weak reference, and then we unwrap
every object reference on entry to a JNI function.  I introduced a new
wrapper class; simply using WeakReference would be wrong as we could
then end up automatically unwrapping a WeakReference which didn't
originate in the JNI code.

This unwrapping requirement makes the code harder to maintain.  I
couldn't see any other way to implement this feature though.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* Makefile.in: Rebuilt.
	* Makefile.am (ordinary_java_source_files): Added JNIWeakRef.java.
	* jni.cc: Include JNIWeakRef.h.
	(unwrap): New function.
	(_Jv_JNI_DefineClass): Use it.
	(_Jv_JNI_GetSuperclass): Likewise.
	(_Jv_JNI_IsAssignableFrom): Likewise.
	(_Jv_JNI_Throw): Likewise.
	(_Jv_JNI_ThrowNew): Likewise.
	(_Jv_JNI_IsSameObject): Likewise.
	(_Jv_JNI_AllocObject): Likewise.
	(_Jv_JNI_GetObjectClass): Likewise.
	(_Jv_JNI_IsInstanceOf): Likewise.
	(_Jv_JNI_GetAnyMethodID): Likewise.
	(array_from_valist): Likewise.
	(_Jv_JNI_CallAnyMethodV): Likewise.
	(_Jv_JNI_CallAnyMethodA): Likewise.
	(_Jv_JNI_CallAnyVoidMethodV): Likewise.
	(_Jv_JNI_CallAnyVoidMethodA): Likewise.
	(_Jv_JNI_CallStaticMethodV): Likewise.
	(_Jv_JNI_CallStaticMethod): Likewise.
	(_Jv_JNI_CallStaticMethodA): Likewise.
	(_Jv_JNI_NewObjectV): Likewise.
	(_Jv_JNI_NewObject): Likewise.
	(_Jv_JNI_NewObjectA): Likewise.
	(_Jv_JNI_GetField): Likewise.
	(_Jv_JNI_SetField): Likewise.
	(_Jv_JNI_GetAnyFieldID): Likewise.
	(_Jv_JNI_SetStaticField): Likewise.
	(_Jv_JNI_GetStringLength): Likewise.
	(_Jv_JNI_GetStringChars): Likewise.
	(_Jv_JNI_ReleaseStringChars): Likewise.
	(_Jv_JNI_GetStringUTFLength): Likewise
	(_Jv_JNI_GetStringUTFChars): Likewise.
	(_Jv_JNI_GetStringRegion): Likewise.
	(_Jv_JNI_GetStringUTFRegion): Likewise.
	(_Jv_JNI_GetStringCritical): Likewise.
	(_Jv_JNI_GetArrayLength): Likewise.
	(_Jv_JNI_NewObjectArray): Likewise.
	(_Jv_JNI_GetObjectArrayElement): Likewise.
	(_Jv_JNI_SetObjectArrayElement): Likewise.
	(_Jv_JNI_GetPrimitiveArrayElements): Likewise.
	(_Jv_JNI_ReleasePrimitiveArrayElements): Likewise.
	(_Jv_JNI_GetPrimitiveArrayRegion): Likewise.
	(_Jv_JNI_SetPrimitiveArrayRegion): Likewise.
	(_Jv_JNI_MonitorEnter): Likewise.
	(_Jv_JNI_MonitorExit): Likewise.
	(_Jv_JNI_ToReflectedField): Likewise.
	(_Jv_JNI_FromReflectedField): Likewise.
	(_Jv_JNI_ToReflectedMethod): Likewise.
	(_Jv_JNI_FromReflectedMethod): Likewise.
	(_Jv_JNI_NewGlobalRef): Likewise.
	(_Jv_JNI_DeleteGlobalRef): Likewise.
	(_Jv_JNI_DeleteLocalRef): Likewise.
	(_Jv_JNI_NewLocalRef): Likewise.
	(_Jv_JNI_NewWeakGlobalRef): New function.
	(_Jv_JNI_DeleteWeakGlobalRef): Likewise.
	(_Jv_JNIFunctions): Updated for new methods.
	(NOT_IMPL): Removed.
	* gnu/gcj/runtime/JNIWeakRef.java: New file.

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.182
diff -u -r1.182 Makefile.am
--- Makefile.am 2001/11/05 23:39:54 1.182
+++ Makefile.am 2001/11/07 17:40:49
@@ -1263,6 +1263,7 @@
 gnu/gcj/runtime/FileDeleter.java \
 gnu/gcj/runtime/FinalizerThread.java \
 gnu/gcj/runtime/FirstThread.java \
+gnu/gcj/runtime/JNIWeakRef.java \
 gnu/gcj/runtime/SharedLibLoader.java \
 gnu/gcj/runtime/VMClassLoader.java \
 gnu/java/io/ClassLoaderObjectInputStream.java \
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.in,v
retrieving revision 1.193
diff -u -r1.193 Makefile.in
--- Makefile.in 2001/11/05 23:39:54 1.193
+++ Makefile.in 2001/11/07 17:40:51
@@ -996,6 +996,7 @@
 gnu/gcj/runtime/FileDeleter.java \
 gnu/gcj/runtime/FinalizerThread.java \
 gnu/gcj/runtime/FirstThread.java \
+gnu/gcj/runtime/JNIWeakRef.java \
 gnu/gcj/runtime/SharedLibLoader.java \
 gnu/gcj/runtime/VMClassLoader.java \
 gnu/java/io/ClassLoaderObjectInputStream.java \
@@ -1636,7 +1637,7 @@
 .deps/gnu/gcj/protocol/jar/Handler.P \
 .deps/gnu/gcj/runtime/FileDeleter.P \
 .deps/gnu/gcj/runtime/FinalizerThread.P \
-.deps/gnu/gcj/runtime/FirstThread.P \
+.deps/gnu/gcj/runtime/FirstThread.P .deps/gnu/gcj/runtime/JNIWeakRef.P \
 .deps/gnu/gcj/runtime/SharedLibLoader.P \
 .deps/gnu/gcj/runtime/VMClassLoader.P \
 .deps/gnu/gcj/runtime/natFinalizerThread.P \
Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.54
diff -u -r1.54 jni.cc
--- jni.cc 2001/10/30 10:14:48 1.54
+++ jni.cc 2001/11/07 17:40:53
@@ -41,6 +41,7 @@
 #include <java/lang/Integer.h>
 #include <java/lang/ThreadGroup.h>
 #include <java/lang/Thread.h>
+#include <gnu/gcj/runtime/JNIWeakRef.h>
 
 #include <gcj/method.h>
 #include <gcj/field.h>
@@ -194,11 +195,34 @@
     ref_table->put (obj, new Integer (val));
 }
 
+// "Unwrap" some random non-reference type.  This exists to simplify
+// other template functions.
+template<typename T>
+static T
+unwrap (T val)
+{
+  return val;
+}
+
+// Unwrap a weak reference, if required.
+template<typename T>
+static T *
+unwrap (T *obj)
+{
+  using namespace gnu::gcj::runtime;
+  if (obj == NULL || ! JNIWeakRef::class$.isInstance (obj))
+    return obj;
+  JNIWeakRef *wr = reinterpret_cast<JNIWeakRef *> (obj);
+  return reinterpret_cast<T *> (wr->get ());
+}
+
 
 
 static jobject
 _Jv_JNI_NewGlobalRef (JNIEnv *, jobject obj)
 {
+  // This seems weird but I think it is correct.
+  obj = unwrap (obj);
   mark_for_gc (obj, global_ref_table);
   return obj;
 }
@@ -206,6 +230,8 @@
 static void
 _Jv_JNI_DeleteGlobalRef (JNIEnv *, jobject obj)
 {
+  // This seems weird but I think it is correct.
+  obj = unwrap (obj);
   unmark_for_gc (obj, global_ref_table);
 }
 
@@ -214,6 +240,9 @@
 {
   _Jv_JNI_LocalFrame *frame;
 
+  // This seems weird but I think it is correct.
+  obj = unwrap (obj);
+
   for (frame = env->locals; frame != NULL; frame = frame->next)
     {
       for (int i = 0; i < frame->size; ++i)
@@ -277,6 +306,9 @@
 static jobject
 _Jv_JNI_NewLocalRef (JNIEnv *env, jobject obj)
 {
+  // This seems weird but I think it is correct.
+  obj = unwrap (obj);
+
   // Try to find an open slot somewhere in the topmost frame.
   _Jv_JNI_LocalFrame *frame = env->locals;
   bool done = false, set = false;
@@ -403,6 +435,8 @@
 {
   try
     {
+      loader = unwrap (loader);
+
       jbyteArray bytes = JvNewByteArray (bufLen);
 
       jbyte *elts = elements (bytes);
@@ -460,19 +494,20 @@
 static jclass
 _Jv_JNI_GetSuperclass (JNIEnv *env, jclass clazz)
 {
-  return (jclass) wrap_value (env, clazz->getSuperclass ());
+  return (jclass) wrap_value (env, unwrap (clazz)->getSuperclass ());
 }
 
 static jboolean
 _Jv_JNI_IsAssignableFrom(JNIEnv *, jclass clazz1, jclass clazz2)
 {
-  return clazz1->isAssignableFrom (clazz2);
+  return unwrap (clazz1)->isAssignableFrom (unwrap (clazz2));
 }
 
 static jint
 _Jv_JNI_Throw (JNIEnv *env, jthrowable obj)
 {
   // We check in case the user did some funky cast.
+  obj = unwrap (obj);
   JvAssert (obj != NULL && java::lang::Throwable::class$.isInstance (obj));
   env->ex = obj;
   return 0;
@@ -483,6 +518,7 @@
 {
   using namespace java::lang::reflect;
 
+  clazz = unwrap (clazz);
   JvAssert (java::lang::Throwable::class$.isAssignableFrom (clazz));
 
   int r = JNI_OK;
@@ -550,7 +586,7 @@
 static jboolean
 _Jv_JNI_IsSameObject (JNIEnv *, jobject obj1, jobject obj2)
 {
-  return obj1 == obj2;
+  return unwrap (obj1) == unwrap (obj2);
 }
 
 static jobject
@@ -561,6 +597,7 @@
 
   try
     {
+      clazz = unwrap (clazz);
       JvAssert (clazz && ! clazz->isArray ());
       if (clazz->isInterface() || Modifier::isAbstract(clazz->getModifiers()))
 	env->ex = new java::lang::InstantiationException ();
@@ -581,6 +618,7 @@
 static jclass
 _Jv_JNI_GetObjectClass (JNIEnv *env, jobject obj)
 {
+  obj = unwrap (obj);
   JvAssert (obj);
   return (jclass) wrap_value (env, obj->getClass());
 }
@@ -588,7 +626,7 @@
 static jboolean
 _Jv_JNI_IsInstanceOf (JNIEnv *, jobject obj, jclass clazz)
 {
-  return clazz->isInstance(obj);
+  return unwrap (clazz)->isInstance(unwrap (obj));
 }
 
 
@@ -604,6 +642,7 @@
 {
   try
     {
+      clazz = unwrap (clazz);
       _Jv_InitClass (clazz);
 
       _Jv_Utf8Const *name_u = _Jv_makeUtf8Const ((char *) name, -1);
@@ -676,7 +715,7 @@
       else
 	{
 	  // An object.
-	  values[i].l = va_arg (vargs, jobject);
+	  values[i].l = unwrap (va_arg (vargs, jobject));
 	}
     }
 }
@@ -688,6 +727,9 @@
 _Jv_JNI_CallAnyMethodV (JNIEnv *env, jobject obj, jclass klass,
 			jmethodID id, va_list vargs)
 {
+  obj = unwrap (obj);
+  klass = unwrap (klass);
+
   if (style == normal)
     id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
 
@@ -748,6 +790,9 @@
 _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass,
 			jmethodID id, jvalue *args)
 {
+  obj = unwrap (obj);
+  klass = unwrap (klass);
+
   if (style == normal)
     id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
 
@@ -765,10 +810,21 @@
       if (style == constructor)
 	return_type = klass;
 
+      // Unwrap arguments as required.  Eww.
+      jclass *type_elts = elements (arg_types);
+      jvalue arg_copy[arg_types->length];
+      for (int i = 0; i < arg_types->length; ++i)
+	{
+	  if (type_elts[i]->isPrimitive ())
+	    arg_copy[i] = args[i];
+	  else
+	    arg_copy[i] = unwrap (args[i]);
+	}
+
       jvalue result;
       jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
 					  style == constructor,
-					  arg_types, args, &result);
+					  arg_types, arg_copy, &result);
 
       if (ex != NULL)
 	env->ex = ex;
@@ -789,6 +845,9 @@
 _Jv_JNI_CallAnyVoidMethodV (JNIEnv *env, jobject obj, jclass klass,
 			    jmethodID id, va_list vargs)
 {
+  obj = unwrap (obj);
+  klass = unwrap (klass);
+
   if (style == normal)
     id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
 
@@ -852,6 +911,17 @@
       _Jv_GetTypesFromSignature (id, decl_class,
 				 &arg_types, &return_type);
 
+      // Unwrap arguments as required.  Eww.
+      jclass *type_elts = elements (arg_types);
+      jvalue arg_copy[arg_types->length];
+      for (int i = 0; i < arg_types->length; ++i)
+	{
+	  if (type_elts[i]->isPrimitive ())
+	    arg_copy[i] = args[i];
+	  else
+	    arg_copy[i] = unwrap (args[i]);
+	}
+
       jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
 					  style == constructor,
 					  arg_types, args, NULL);
@@ -929,7 +999,7 @@
 			   jmethodID id, va_list args)
 {
   JvAssert (((id->accflags) & java::lang::reflect::Modifier::STATIC));
-  JvAssert (java::lang::Class::class$.isInstance (klass));
+  JvAssert (java::lang::Class::class$.isInstance (unwrap (klass)));
 
   return _Jv_JNI_CallAnyMethodV<T, static_type> (env, NULL, klass, id, args);
 }
@@ -944,7 +1014,7 @@
   T result;
 
   JvAssert (((id->accflags) & java::lang::reflect::Modifier::STATIC));
-  JvAssert (java::lang::Class::class$.isInstance (klass));
+  JvAssert (java::lang::Class::class$.isInstance (unwrap (klass)));
 
   va_start (args, id);
   result = _Jv_JNI_CallAnyMethodV<T, static_type> (env, NULL, klass,
@@ -962,7 +1032,7 @@
 			   jvalue *args)
 {
   JvAssert (((id->accflags) & java::lang::reflect::Modifier::STATIC));
-  JvAssert (java::lang::Class::class$.isInstance (klass));
+  JvAssert (java::lang::Class::class$.isInstance (unwrap (klass)));
 
   return _Jv_JNI_CallAnyMethodA<T, static_type> (env, NULL, klass, id, args);
 }
@@ -1048,6 +1118,7 @@
 static T
 _Jv_JNI_GetField (JNIEnv *env, jobject obj, jfieldID field)
 {
+  obj = unwrap (obj);
   JvAssert (obj);
   T *ptr = (T *) ((char *) obj + field->getOffset ());
   return wrap_value (env, *ptr);
@@ -1057,6 +1128,9 @@
 static void
 _Jv_JNI_SetField (JNIEnv *, jobject obj, jfieldID field, T value)
 {
+  obj = unwrap (obj);
+  value = unwrap (value);
+
   JvAssert (obj);
   T *ptr = (T *) ((char *) obj + field->getOffset ());
   *ptr = value;
@@ -1069,6 +1143,8 @@
 {
   try
     {
+      clazz = unwrap (clazz);
+
       _Jv_InitClass (clazz);
 
       _Jv_Utf8Const *a_name = _Jv_makeUtf8Const ((char *) name, -1);
@@ -1133,6 +1209,7 @@
 static void
 _Jv_JNI_SetStaticField (JNIEnv *, jclass, jfieldID field, T value)
 {
+  value = unwrap (value);
   T *ptr = (T *) field->u.addr;
   *ptr = value;
 }
@@ -1155,12 +1232,13 @@
 static jsize
 _Jv_JNI_GetStringLength (JNIEnv *, jstring string)
 {
-  return string->length();
+  return unwrap (string)->length();
 }
 
 static const jchar *
 _Jv_JNI_GetStringChars (JNIEnv *, jstring string, jboolean *isCopy)
 {
+  string = unwrap (string);
   jchar *result = _Jv_GetStringChars (string);
   mark_for_gc (string, global_ref_table);
   if (isCopy)
@@ -1171,7 +1249,7 @@
 static void
 _Jv_JNI_ReleaseStringChars (JNIEnv *, jstring string, const jchar *)
 {
-  unmark_for_gc (string, global_ref_table);
+  unmark_for_gc (unwrap (string), global_ref_table);
 }
 
 static jstring
@@ -1192,12 +1270,13 @@
 static jsize
 _Jv_JNI_GetStringUTFLength (JNIEnv *, jstring string)
 {
-  return JvGetStringUTFLength (string);
+  return JvGetStringUTFLength (unwrap (string));
 }
 
 static const char *
 _Jv_JNI_GetStringUTFChars (JNIEnv *env, jstring string, jboolean *isCopy)
 {
+  string = unwrap (string);
   jsize len = JvGetStringUTFLength (string);
   try
     {
@@ -1227,6 +1306,7 @@
 _Jv_JNI_GetStringRegion (JNIEnv *env, jstring string, jsize start, jsize len,
 			 jchar *buf)
 {
+  string = unwrap (string);
   jchar *result = _Jv_GetStringChars (string);
   if (start < 0 || start > string->length ()
       || len < 0 || start + len > string->length ())
@@ -1248,6 +1328,8 @@
 _Jv_JNI_GetStringUTFRegion (JNIEnv *env, jstring str, jsize start,
 			    jsize len, char *buf)
 {
+  str = unwrap (str);
+    
   if (start < 0 || start > str->length ()
       || len < 0 || start + len > str->length ())
     {
@@ -1267,7 +1349,7 @@
 static const jchar *
 _Jv_JNI_GetStringCritical (JNIEnv *, jstring str, jboolean *isCopy)
 {
-  jchar *result = _Jv_GetStringChars (str);
+  jchar *result = _Jv_GetStringChars (unwrap (str));
   if (isCopy)
     *isCopy = false;
   return result;
@@ -1282,7 +1364,7 @@
 static jsize
 _Jv_JNI_GetArrayLength (JNIEnv *, jarray array)
 {
-  return array->length;
+  return unwrap (array)->length;
 }
 
 static jarray
@@ -1291,6 +1373,9 @@
 {
   try
     {
+      elementClass = unwrap (elementClass);
+      init = unwrap (init);
+
       jarray result = JvNewObjectArray (length, elementClass, init);
       return (jarray) wrap_value (env, result);
     }
@@ -1304,7 +1389,7 @@
 static jobject
 _Jv_JNI_GetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index)
 {
-  jobject *elts = elements (array);
+  jobject *elts = elements (unwrap (array));
   return wrap_value (env, elts[index]);
 }
 
@@ -1314,6 +1399,9 @@
 {
   try
     {
+      array = unwrap (array);
+      value = unwrap (value);
+
       _Jv_CheckArrayStore (array, value);
       jobject *elts = elements (array);
       elts[index] = value;
@@ -1344,6 +1432,7 @@
 _Jv_JNI_GetPrimitiveArrayElements (JNIEnv *, JArray<T> *array,
 				   jboolean *isCopy)
 {
+  array = unwrap (array);
   T *elts = elements (array);
   if (isCopy)
     {
@@ -1359,6 +1448,7 @@
 _Jv_JNI_ReleasePrimitiveArrayElements (JNIEnv *, JArray<T> *array,
 				       T *, jint /* mode */)
 {
+  array = unwrap (array);
   // Note that we ignore MODE.  We can do this because we never copy
   // the array elements.  My reading of the JNI documentation is that
   // this is an option for the implementor.
@@ -1371,6 +1461,8 @@
 				 jsize start, jsize len,
 				 T *buf)
 {
+  array = unwrap (array);
+
   // The cast to unsigned lets us save a comparison.
   if (start < 0 || len < 0
       || (unsigned long) (start + len) > (unsigned long) array->length)
@@ -1398,6 +1490,8 @@
 _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array,
 				 jsize start, jsize len, T *buf)
 {
+  array = unwrap (array);
+
   // The cast to unsigned lets us save a comparison.
   if (start < 0 || len < 0
       || (unsigned long) (start + len) > (unsigned long) array->length)
@@ -1423,6 +1517,7 @@
 _Jv_JNI_GetPrimitiveArrayCritical (JNIEnv *, jarray array,
 				   jboolean *isCopy)
 {
+  array = unwrap (array);
   // FIXME: does this work?
   jclass klass = array->getClass()->getComponentType();
   JvAssert (klass->isPrimitive ());
@@ -1443,7 +1538,7 @@
 {
   try
     {
-      _Jv_MonitorEnter (obj);
+      _Jv_MonitorEnter (unwrap (obj));
       return 0;
     }
   catch (jthrowable t)
@@ -1458,7 +1553,7 @@
 {
   try
     {
-      _Jv_MonitorExit (obj);
+      _Jv_MonitorExit (unwrap (obj));
       return 0;
     }
   catch (jthrowable t)
@@ -1475,6 +1570,7 @@
 {
   try
     {
+      cls = unwrap (cls);
       java::lang::reflect::Field *field = new java::lang::reflect::Field();
       field->declaringClass = cls;
       field->offset = (char*) fieldID - (char *) cls->fields;
@@ -1494,6 +1590,7 @@
 {
   using namespace java::lang::reflect;
 
+  f = unwrap (f);
   Field *field = reinterpret_cast<Field *> (f);
   return _Jv_FromReflectedField (field);
 }
@@ -1505,6 +1602,7 @@
   using namespace java::lang::reflect;
 
   jobject result = NULL;
+  klass = unwrap (klass);
 
   try
     {
@@ -1536,12 +1634,44 @@
 _Jv_JNI_FromReflectedMethod (JNIEnv *, jobject method)
 {
   using namespace java::lang::reflect;
+  method = unwrap (method);
   if (Method::class$.isInstance (method))
     return _Jv_FromReflectedMethod (reinterpret_cast<Method *> (method));
   return
     _Jv_FromReflectedConstructor (reinterpret_cast<Constructor *> (method));
 }
 
+// JDK 1.2.
+jweak
+_Jv_JNI_NewWeakGlobalRef (JNIEnv *env, jobject obj)
+{
+  using namespace gnu::gcj::runtime;
+  JNIWeakRef *ref = NULL;
+
+  try
+    {
+      // This seems weird but I think it is correct.
+      obj = unwrap (obj);
+      ref = new JNIWeakRef (obj);
+      mark_for_gc (ref, global_ref_table);
+    }
+  catch (jthrowable t)
+    {
+      env->ex = t;
+    }
+
+  return reinterpret_cast<jweak> (ref);
+}
+
+void
+_Jv_JNI_DeleteWeakGlobalRef (JNIEnv *, jweak obj)
+{
+  using namespace gnu::gcj::runtime;
+  JNIWeakRef *ref = reinterpret_cast<JNIWeakRef *> (obj);
+  unmark_for_gc (ref, global_ref_table);
+  ref->clear ();
+}
+
 
 
 // Hash table of native methods.
@@ -2218,7 +2348,6 @@
 
 
 
-#define NOT_IMPL NULL
 #define RESERVED NULL
 
 struct JNINativeInterface _Jv_JNIFunctions =
@@ -2462,8 +2591,8 @@
   _Jv_JNI_GetStringCritical,		    // GetStringCritical
   _Jv_JNI_ReleaseStringCritical,	    // ReleaseStringCritical
 
-  NOT_IMPL /* newweakglobalref */,
-  NOT_IMPL /* deleteweakglobalref */,
+  _Jv_JNI_NewWeakGlobalRef,		    // NewWeakGlobalRef
+  _Jv_JNI_DeleteWeakGlobalRef,		    // DeleteWeakGlobalRef
 
   _Jv_JNI_ExceptionCheck
 };
Index: gnu/gcj/runtime/JNIWeakRef.java
===================================================================
RCS file: JNIWeakRef.java
diff -N JNIWeakRef.java
--- /dev/null	Tue May  5 13:32:27 1998
+++ gnu/gcj/runtime/JNIWeakRef.java Wed Nov 7 09:40:53 2001
@@ -0,0 +1,24 @@
+// JNIWeakRef.java - Wrapper class for JNI-specific weak references.
+
+/* Copyright (C) 2001  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+package gnu.gcj.runtime;
+
+import java.lang.ref.*;
+
+// This wrapper is used by the JNI implementation to keep track of
+// global weak references.  Each such reference is wrapped in an
+// instance of this class, and automatically unwrapped when used.
+public final class JNIWeakRef extends WeakReference
+{
+  public JNIWeakRef (Object referent)
+  {
+    super (referent);
+  }
+}


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