fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / testsuite / libjava.jni / martin.c
blob0fbb8d0aa73cc8ac202fc6324f9df2e0d1d3109e
1 #include <jni.h>
2 #include "martin.h"
3 #include <stdio.h>
5 JNIEXPORT void JNICALL
6 Java_martin_myNative(JNIEnv* env, jobject this, jstring s)
8 jclass cls;
9 jfieldID fid;
10 jobject obj;
11 jmethodID mid;
13 printf("From C\n");
14 fflush(stdout);
16 cls = (*env)->FindClass(env, "java/lang/System");
17 if (cls == 0) {
18 printf("java/lang/System lookup failed\n");
19 return;
21 fid = (*env)->GetStaticFieldID(env, cls, "out", "Ljava/io/PrintStream;");
22 if (fid == 0) {
23 printf("java/lang/System::out lookup failed\n");
24 return;
26 obj = (*env)->GetStaticObjectField(env, cls, fid);
27 if (obj == 0) {
28 printf("GetStaticObjectField call failed\n");
29 return;
31 cls = (*env)->GetObjectClass(env, obj);
32 if (cls == 0) {
33 printf("GetObjectClass(out) failed\n");
34 return;
36 mid = (*env)->GetMethodID(env, cls, "println", "(Ljava/lang/String;)V");
37 if (mid == 0) {
38 printf("println method lookup failed\n");
39 return;
41 (*env)->CallVoidMethod(env, obj, mid, s);