[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: archie's JNI fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Mar 21 06:05:28 PST 2005


PatchSet 5578 
Date: 2005/03/21 14:01:04
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: archie's JNI fixes

2005-03-21  Dalibor Topic  <robilad at kaffe.org>

        Resynced with GNU Classpath.

        2005-03-16  Archie Cobbs  <archie at dellroad.org>

        * native/jni/java-nio/java_nio_VMDirectByteBuffer.c: use
        global native reference to wrap persistent jclass variable.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
        use DeleteLocalRef() to avoid exhausting local native references.

Members: 
	ChangeLog:1.3752->1.3753 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:1.7->1.8 
	libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.4->1.5 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3752 kaffe/ChangeLog:1.3753
--- kaffe/ChangeLog:1.3752	Mon Mar 21 01:21:31 2005
+++ kaffe/ChangeLog	Mon Mar 21 14:01:04 2005
@@ -1,3 +1,14 @@
+2005-03-21  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+
+	2005-03-16  Archie Cobbs  <archie at dellroad.org>
+
+        * native/jni/java-nio/java_nio_VMDirectByteBuffer.c: use
+        global native reference to wrap persistent jclass variable.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
+        use DeleteLocalRef() to avoid exhausting local native references.
+
 2003-03-20  Dalibor Topic  <robilad at kaffe.org>
 
 	* configure.ac: Check for -mregnames. It lets us use common register 
Index: kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
diff -u kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:1.7 kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:1.8
--- kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:1.7	Thu Jan 13 08:56:31 2005
+++ kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c	Mon Mar 21 14:01:06 2005
@@ -206,6 +206,7 @@
   jclass formatClass;
   jmethodID addExtensionID;
   jmethodID addMimeTypeID;
+  jobject string;
 
   formatClass = (*env)->FindClass
     (env, "gnu/java/awt/peer/gtk/GdkPixbufDecoder$ImageFormatSpec");
@@ -227,26 +228,33 @@
       format = (GdkPixbufFormat *) f->data;
       name = gdk_pixbuf_format_get_name(format);
 
+      string = (*env)->NewStringUTF(env, name);
+      g_assert(string != NULL);
+
       jformat = (*env)->CallStaticObjectMethod 
-	(env, clazz, registerFormatID, 				    
-	 (*env)->NewStringUTF(env, name),
+	(env, clazz, registerFormatID, string,
 	 (jboolean) gdk_pixbuf_format_is_writable(format));
+      (*env)->DeleteLocalRef(env, string);
 
       g_assert(jformat != NULL);
       
       ch = gdk_pixbuf_format_get_extensions(format);
       while (*ch)
 	{
-	  (*env)->CallVoidMethod (env, jformat, addExtensionID, 
-				  (*env)->NewStringUTF(env, *ch)); 
+	  string = (*env)->NewStringUTF(env, *ch);
+	  g_assert(string != NULL);
+	  (*env)->CallVoidMethod (env, jformat, addExtensionID, string);
+	  (*env)->DeleteLocalRef(env, string);
 	  ++ch;
 	}
       
       ch = gdk_pixbuf_format_get_mime_types(format);
       while (*ch)
 	{
-	  (*env)->CallVoidMethod (env, jformat, addMimeTypeID, 
-				  (*env)->NewStringUTF(env, *ch)); 
+	  string = (*env)->NewStringUTF(env, *ch);
+	  g_assert(string != NULL);
+	  (*env)->CallVoidMethod (env, jformat, addMimeTypeID, string);
+	  (*env)->DeleteLocalRef(env, string);
 	  ++ch;
 	}
     }
Index: kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c
diff -u kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.4 kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.5
--- kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.4	Thu Feb 10 23:23:32 2005
+++ kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c	Mon Mar 21 14:01:06 2005
@@ -135,6 +135,14 @@
 #else
 #error unsupported pointer size
 #endif
+
+  /* We need to wrap the jclass in global reference to make it persistent */
+  if ((classRawData = (*env)->NewGlobalRef(env, classRawData)) == NULL)
+    {
+      JCL_ThrowException(env, "java/lang/InternalError",
+			      "failed to create global reference");
+      return;
+    }
 }
 
 JNIEXPORT jobject JNICALL




More information about the kaffe mailing list