Patch: FYI: JNI bug fix
Tom Tromey
tromey@redhat.com
Thu Jan 18 20:47:00 GMT 2007
I'm checking this in.
A while back Marco showed a JNI bug in loadclass and sent a test
case. I've cleaned it up and fixed the bug.
Tom
Index: ChangeLog
from Marco Trudel <mtrudel@gmx.ch>
* jni.cc (_Jv_JNI_FindClass): Initialize class.
* testsuite/libjava.jni/findclass2.jar: New file.
* testsuite/libjava.jni/findclass2.h: New file.
* testsuite/libjava.jni/findclass2.java: New file
* testsuite/libjava.jni/findclass2.c: New file.
* testsuite/libjava.jni/findclass2.out: New file.
Index: testsuite/libjava.jni/findclass2.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: testsuite/libjava.jni/findclass2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: testsuite/libjava.jni/findclass2.c
===================================================================
--- testsuite/libjava.jni/findclass2.c (revision 0)
+++ testsuite/libjava.jni/findclass2.c (revision 0)
@@ -0,0 +1,9 @@
+#include <stdlib.h>
+
+#include <findclass2.h>
+
+JNIEXPORT void JNICALL
+Java_findclass2_searchClass (JNIEnv *env, jclass klass)
+{
+ (*env)->FindClass (env, "findclass2$inner");
+}
Index: testsuite/libjava.jni/findclass2.h
===================================================================
--- testsuite/libjava.jni/findclass2.h (revision 0)
+++ testsuite/libjava.jni/findclass2.h (revision 0)
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#ifndef __findclass2__
+#define __findclass2__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_findclass2_searchClass (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __findclass2__ */
Index: testsuite/libjava.jni/findclass2.out
===================================================================
--- testsuite/libjava.jni/findclass2.out (revision 0)
+++ testsuite/libjava.jni/findclass2.out (revision 0)
@@ -0,0 +1 @@
+hello
Index: testsuite/libjava.jni/findclass2.java
===================================================================
--- testsuite/libjava.jni/findclass2.java (revision 0)
+++ testsuite/libjava.jni/findclass2.java (revision 0)
@@ -0,0 +1,24 @@
+// Test that FindClass initializes the class.
+
+public class findclass2
+{
+ public static class inner
+ {
+ static
+ {
+ System.out.println("hello");
+ }
+ }
+
+ public static native void searchClass();
+
+ static
+ {
+ System.loadLibrary("findclass2");
+ }
+
+ public static void main(String[] args)
+ {
+ searchClass();
+ }
+}
Index: jni.cc
===================================================================
--- jni.cc (revision 120900)
+++ jni.cc (working copy)
@@ -1,6 +1,6 @@
// jni.cc - JNI implementation, including the jump table.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation
This file is part of libgcj.
@@ -552,6 +552,7 @@
}
r = loader->loadClass (n);
+ _Jv_InitClass (r);
}
catch (jthrowable t)
{
More information about the Java-patches
mailing list