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]

Re: Patch: FYI: test case for JNI interface call regression


>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> I'll try this test with 3.4 as well.

The test passes in the 3.4 build tree.  However, if I modify it a
little, and run it interpreted, it fails.  So, that's interesting.

Here's the modified test case.  I'll look into updating our test suite
to run the interpreter as well as the compiled jni test case.

Tom

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

	* testsuite/libjava.jni/iface.c: New file.
	* testsuite/libjava.jni/iface.out: New file.
	* testsuite/libjava.jni/iface.java: New file.

Index: testsuite/libjava.jni/iface.c
===================================================================
RCS file: testsuite/libjava.jni/iface.c
diff -N testsuite/libjava.jni/iface.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libjava.jni/iface.c 16 Dec 2004 19:58:02 -0000
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <iface.h>
+
+void check (JNIEnv *);
+
+void check(JNIEnv *env)
+{
+  if ((*env)->ExceptionCheck(env) != JNI_FALSE)
+    {
+      fprintf(stderr, "UNEXPECTED EXCEPTION\n");
+      exit(-1);
+    }
+}
+
+void
+Java_iface_doCalls (JNIEnv *env, jobject self, jobject other)
+{
+  jclass iface_class, comparable_class;
+  jmethodID iface_meth, comparable_meth;
+  jvalue args[1];
+
+  iface_class = (*env)->FindClass(env, "iface");
+  check (env);
+  comparable_class = (*env)->FindClass (env, "mycomp");
+  check (env);
+
+  iface_meth = (*env)->GetMethodID (env, iface_class, "compareTo",
+				    "(Ljava/lang/Object;)I");
+  check (env);
+  comparable_meth = (*env)->GetMethodID (env, comparable_class, "compareTo",
+					 "(Ljava/lang/Object;)I");
+  check (env);
+
+  args[0].l = other;
+  (*env)->CallObjectMethodA (env, self, iface_meth, args);
+  check (env);
+  (*env)->CallObjectMethodA (env, self, comparable_meth, args);
+  check (env);
+}
Index: testsuite/libjava.jni/iface.java
===================================================================
RCS file: testsuite/libjava.jni/iface.java
diff -N testsuite/libjava.jni/iface.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libjava.jni/iface.java 16 Dec 2004 19:58:02 -0000
@@ -0,0 +1,27 @@
+// JNI calls via an interface method were broken in a couple releases.
+
+interface mycomp
+{
+  int compareTo(Object x);
+}
+
+public class iface implements mycomp
+{
+  static
+  {
+    System.loadLibrary("iface");
+  }
+
+  public int compareTo (Object x)
+  {
+    System.out.println ("hi maude");
+    return 3;
+  }
+
+  public native void doCalls(Object x);
+
+  public static void main (String[] args)
+  {
+    new iface().doCalls(args);
+  }
+}
Index: testsuite/libjava.jni/iface.out
===================================================================
RCS file: testsuite/libjava.jni/iface.out
diff -N testsuite/libjava.jni/iface.out
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libjava.jni/iface.out 16 Dec 2004 19:58:02 -0000
@@ -0,0 +1,2 @@
+hi maude
+hi maude


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