summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.jni
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-21 00:49:45 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-21 00:49:45 +0000
commit5bfde3cace5b7cdc9397392780a8d6385c9ecde2 (patch)
treeebad3395e1e19c088c5c220227ad303db595561a /libjava/testsuite/libjava.jni
parentca02e838f840444e2b577065654727ddfa8061e2 (diff)
downloadgcc-5bfde3cace5b7cdc9397392780a8d6385c9ecde2.tar.gz
PR java/15001
* testsuite/libjava.jni/iface.c: New file. * testsuite/libjava.jni/iface.out: New file. * testsuite/libjava.jni/iface.java: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92445 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/testsuite/libjava.jni')
-rw-r--r--libjava/testsuite/libjava.jni/iface.c40
-rw-r--r--libjava/testsuite/libjava.jni/iface.java27
-rw-r--r--libjava/testsuite/libjava.jni/iface.out2
3 files changed, 69 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jni/iface.c b/libjava/testsuite/libjava.jni/iface.c
new file mode 100644
index 00000000000..6d33dc01f25
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/iface.c
@@ -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);
+}
diff --git a/libjava/testsuite/libjava.jni/iface.java b/libjava/testsuite/libjava.jni/iface.java
new file mode 100644
index 00000000000..c878ae362ea
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/iface.java
@@ -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);
+ }
+}
diff --git a/libjava/testsuite/libjava.jni/iface.out b/libjava/testsuite/libjava.jni/iface.out
new file mode 100644
index 00000000000..4eb3a1b43f7
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/iface.out
@@ -0,0 +1,2 @@
+hi maude
+hi maude