[kaffe] CVS kaffe (robilad): Warning fixes for jni tests
Kaffe CVS
cvs-commits at kaffe.org
Thu Sep 8 19:34:14 PDT 2005
PatchSet 6882
Date: 2005/09/09 02:29:14
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Warning fixes for jni tests
2005-09-09 Dalibor Topic <robilad at kaffe.org>
* test/jni/jniBase.c (main): Turned env into a void*. Added
JNIEnv* jni_env. Set jni_env to env after VM is created. Use
jni_env in the rest of function.
* test/jni/jniExecClass.c (main): Likewise.
* test/jni/jniReflect.c (main): Likewise.
* test/jni/jniWeakTest.c (main): Likewise.
Reported by: Andreas Tobler <a.tobler at schweiz.ch>
Members:
ChangeLog:1.4403->1.4404
test/jni/jniBase.c:1.1->1.2
test/jni/jniExecClass.c:1.1->1.2
test/jni/jniReflect.c:1.1->1.2
test/jni/jniWeakTest.c:1.2->1.3
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4403 kaffe/ChangeLog:1.4404
--- kaffe/ChangeLog:1.4403 Thu Sep 8 15:48:11 2005
+++ kaffe/ChangeLog Fri Sep 9 02:29:14 2005
@@ -1,3 +1,14 @@
+2005-09-09 Dalibor Topic <robilad at kaffe.org>
+
+ * test/jni/jniBase.c (main): Turned env into a void*. Added
+ JNIEnv* jni_env. Set jni_env to env after VM is created. Use
+ jni_env in the rest of function.
+ * test/jni/jniExecClass.c (main): Likewise.
+ * test/jni/jniReflect.c (main): Likewise.
+ * test/jni/jniWeakTest.c (main): Likewise.
+
+ Reported by: Andreas Tobler <a.tobler at schweiz.ch>
+
2005-09-08 Andreas Tobler <a.tobler at schweiz.ch>
* kaffe/kaffe/main.c
Index: kaffe/test/jni/jniBase.c
diff -u kaffe/test/jni/jniBase.c:1.1 kaffe/test/jni/jniBase.c:1.2
--- kaffe/test/jni/jniBase.c:1.1 Fri Jul 9 15:44:30 2004
+++ kaffe/test/jni/jniBase.c Fri Sep 9 02:29:15 2005
@@ -30,7 +30,7 @@
{
JavaVMInitArgs vmargs;
JavaVM *vm;
- JNIEnv *env;
+ void *env;
JavaVMOption myoptions[1];
/* set up libtool/libltdl dlopen emulation */
@@ -49,7 +49,7 @@
vmargs.nOptions = 1;
vmargs.options = myoptions;
- if (JNI_CreateJavaVM (&vm, (void **)&env, &vmargs) < 0)
+ if (JNI_CreateJavaVM (&vm, &env, &vmargs) < 0)
{
fprintf(stderr, " Cannot create the Java VM\n");
return 1;
Index: kaffe/test/jni/jniExecClass.c
diff -u kaffe/test/jni/jniExecClass.c:1.1 kaffe/test/jni/jniExecClass.c:1.2
--- kaffe/test/jni/jniExecClass.c:1.1 Fri Jul 9 15:44:30 2004
+++ kaffe/test/jni/jniExecClass.c Fri Sep 9 02:29:15 2005
@@ -29,7 +29,8 @@
{
JavaVMInitArgs vmargs;
JavaVM *vm;
- JNIEnv *env;
+ void *env;
+ JNIEnv* jni_env;
JavaVMOption myoptions[2];
jclass cls, scls;
jarray args;
@@ -56,37 +57,39 @@
fprintf(stderr, " Cannot create the Java VM\n");
return 1;
}
+
+ jni_env = env;
- cls = (*env)->FindClass(env, "HelloWorldApp");
- if ((*env)->ExceptionOccurred(env))
+ cls = (*jni_env)->FindClass(jni_env, "HelloWorldApp");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "FindClass has failed\n");
return 1;
}
- mainid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
- if ((*env)->ExceptionOccurred(env))
+ mainid = (*jni_env)->GetStaticMethodID(jni_env, cls, "main", "([Ljava/lang/String;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "GetStaticMethodID has failed\n");
return 1;
}
- scls = (*env)->FindClass(env, "java/lang/String");
- if ((*env)->ExceptionOccurred(env))
+ scls = (*jni_env)->FindClass(jni_env, "java/lang/String");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "FindClass(java/lang/String) has failed\n");
return 1;
}
- args = (*env)->NewObjectArray(env, 0, scls, 0);
- if ((*env)->ExceptionOccurred(env))
+ args = (*jni_env)->NewObjectArray(jni_env, 0, scls, 0);
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "NewObjectArray has failed\n");
return 1;
}
- (*env)->CallStaticVoidMethod(env, cls, mainid, args);
- if ((*env)->ExceptionOccurred(env))
+ (*jni_env)->CallStaticVoidMethod(jni_env, cls, mainid, args);
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "CallStaticMethod has failed\n");
return 1;
Index: kaffe/test/jni/jniReflect.c
diff -u kaffe/test/jni/jniReflect.c:1.1 kaffe/test/jni/jniReflect.c:1.2
--- kaffe/test/jni/jniReflect.c:1.1 Sun Jul 11 08:55:12 2004
+++ kaffe/test/jni/jniReflect.c Fri Sep 9 02:29:15 2005
@@ -29,7 +29,8 @@
{
JavaVMInitArgs vmargs;
JavaVM *vm;
- JNIEnv *env;
+ void *env;
+ JNIEnv *jni_env;
JavaVMOption myoptions[2];
jclass cls, refcls;
jmethodID mainid, nameid;
@@ -60,53 +61,55 @@
fprintf(stderr, " Cannot create the Java VM\n");
return 1;
}
+
+ jni_env = env;
- cls = (*env)->FindClass(env, "HelloWorldApp");
- if ((*env)->ExceptionOccurred(env))
+ cls = (*jni_env)->FindClass(jni_env, "HelloWorldApp");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "FindClass has failed\n");
return 1;
}
- mainid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
- if ((*env)->ExceptionOccurred(env))
+ mainid = (*jni_env)->GetStaticMethodID(jni_env, cls, "main", "([Ljava/lang/String;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "GetStaticMethodID has failed\n");
return 1;
}
- reflect = (*env)->ToReflectedMethod(env, cls, mainid, 1);
- if (reflect == NULL || (*env)->ExceptionOccurred(env))
+ reflect = (*jni_env)->ToReflectedMethod(jni_env, cls, mainid, 1);
+ if (reflect == NULL || (*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "ToReflectedMethod has failed\n");
return 1;
}
- refcls = (*env)->FindClass(env, "java/lang/reflect/Method");
- if ((*env)->ExceptionOccurred(env))
+ refcls = (*jni_env)->FindClass(jni_env, "java/lang/reflect/Method");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "FindClass(java/lang/reflect/Method has failed\n");
return 1;
}
- nameid = (*env)->GetMethodID(env, refcls, "getName", "()Ljava/lang/String;");
- if ((*env)->ExceptionOccurred(env))
+ nameid = (*jni_env)->GetMethodID(jni_env, refcls, "getName", "()Ljava/lang/String;");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "GetMethodID has failed\n");
return 1;
}
- name = (*env)->CallObjectMethod(env, reflect, nameid);
- if ((*env)->ExceptionOccurred(env))
+ name = (*jni_env)->CallObjectMethod(jni_env, reflect, nameid);
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "getName() has failed\n");
return 1;
}
isCopy = 0;
- name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
+ name_utf = (*jni_env)->GetStringUTFChars(jni_env, name, &isCopy);
- (*env)->ReleaseStringChars(env, name, name_utf);
+ (*jni_env)->ReleaseStringChars(jni_env, name, name_utf);
(*vm)->DestroyJavaVM(vm);
Index: kaffe/test/jni/jniWeakTest.c
diff -u kaffe/test/jni/jniWeakTest.c:1.2 kaffe/test/jni/jniWeakTest.c:1.3
--- kaffe/test/jni/jniWeakTest.c:1.2 Mon Aug 1 20:53:45 2005
+++ kaffe/test/jni/jniWeakTest.c Fri Sep 9 02:29:15 2005
@@ -29,7 +29,8 @@
{
JavaVMInitArgs vmargs;
JavaVM *vm;
- JNIEnv *env;
+ void *env;
+ JNIEnv *jni_env;
JavaVMOption myoptions[3];
jclass cls, scls;
jarray args;
@@ -58,38 +59,40 @@
fprintf(stderr, " Cannot create the Java VM\n");
return 1;
}
+
+ jni_env = env;
- cls = (*env)->FindClass(env, "JNIWeakTest");
- if ((*env)->ExceptionOccurred(env))
+ cls = (*jni_env)->FindClass(jni_env, "JNIWeakTest");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
- (*env)->ExceptionDescribe(env);
+ (*jni_env)->ExceptionDescribe(jni_env);
fprintf(stderr, "FindClass has failed\n");
return 1;
}
- mainid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
- if ((*env)->ExceptionOccurred(env))
+ mainid = (*jni_env)->GetStaticMethodID(jni_env, cls, "main", "([Ljava/lang/String;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "GetStaticMethodID has failed\n");
return 1;
}
- scls = (*env)->FindClass(env, "java/lang/String");
- if ((*env)->ExceptionOccurred(env))
+ scls = (*jni_env)->FindClass(jni_env, "java/lang/String");
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "FindClass(java/lang/String) has failed\n");
return 1;
}
- args = (*env)->NewObjectArray(env, 0, scls, 0);
- if ((*env)->ExceptionOccurred(env))
+ args = (*jni_env)->NewObjectArray(jni_env, 0, scls, 0);
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "NewObjectArray has failed\n");
return 1;
}
- (*env)->CallStaticVoidMethod(env, cls, mainid, args);
- if ((*env)->ExceptionOccurred(env))
+ (*jni_env)->CallStaticVoidMethod(jni_env, cls, mainid, args);
+ if ((*jni_env)->ExceptionOccurred(jni_env))
{
fprintf(stderr, "CallStaticMethod has failed\n");
return 1;
More information about the kaffe
mailing list