2007-02-13 Andrew Haley <aph@redhat.com>
[gcc.git] / libjava / testsuite / libjava.jni / iface.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <iface.h>
4
5 void check (JNIEnv *);
6
7 void check(JNIEnv *env)
8 {
9 if ((*env)->ExceptionCheck(env) != JNI_FALSE)
10 {
11 fprintf(stderr, "UNEXPECTED EXCEPTION\n");
12 exit(-1);
13 }
14 }
15
16 void
17 Java_iface_doCalls (JNIEnv *env, jobject self, jobject other)
18 {
19 jclass iface_class, comparable_class;
20 jmethodID iface_meth, comparable_meth;
21 jvalue args[1];
22
23 iface_class = (*env)->FindClass(env, "iface");
24 check (env);
25 comparable_class = (*env)->FindClass (env, "mycomp");
26 check (env);
27
28 iface_meth = (*env)->GetMethodID (env, iface_class, "compareTo",
29 "(Ljava/lang/Object;)I");
30 check (env);
31 comparable_meth = (*env)->GetMethodID (env, comparable_class, "compareTo",
32 "(Ljava/lang/Object;)I");
33 check (env);
34
35 args[0].l = other;
36 (*env)->CallObjectMethodA (env, self, iface_meth, args);
37 check (env);
38 (*env)->CallObjectMethodA (env, self, comparable_meth, args);
39 check (env);
40 }