re PR libgcj/15001 ([3.4 only] Using JNI with interpreter and interface methods yields SIGSEGV)

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

From-SVN: r92445
This commit is contained in:
Tom Tromey 2004-12-21 00:49:45 +00:00 committed by Tom Tromey
parent f8c940c55c
commit 90d8362105
4 changed files with 76 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2004-12-20 Tom Tromey <tromey@redhat.com>
PR java/15001
* testsuite/libjava.jni/iface.c: New file.
* testsuite/libjava.jni/iface.out: New file.
* testsuite/libjava.jni/iface.java: New file.
2004-12-19 Kelley Cook <kcook@gcc.gnu.org>
* include/config.h.in: Regenerate.

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -0,0 +1,2 @@
hi maude
hi maude