Another endianess problem on Solaris
Martin Kahlert
martin.kahlert@infineon.com
Fri Feb 8 05:51:00 GMT 2002
Hi!
I think, i found an endianess problem on Solaris with boolean:
$ cat chello.c
#include <jni.h>
#include <stdio.h>
int main()
{
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jobjectArray args;
char classpath[1024];
jboolean result;
vm_args.version = JNI_VERSION_1_2;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0)
{
fprintf(stderr, "Can't create Java VM\n");
exit(1);
}
cls = (*env)->FindClass(env, "hello");
if (cls == 0) {
fprintf(stderr, "Can't find hello class\n");
exit(1);
}
mid = (*env)->GetStaticMethodID(env, cls, "testme", "()Z");
if (mid == 0) {
fprintf(stderr, "Can't find testme\n");
exit(1);
}
result = (*env)->CallStaticBooleanMethod(env, cls, mid, args);
if (result)
puts("o.k.");
else
puts("not o.k.");
(*jvm)->DestroyJavaVM(jvm);
}
$ cat hello.java
public class hello
{
public static boolean testme()
{
return true;
}
}
$ gcc -g -c chello.c
$ gcj -g --encoding=UTF-8 -c hello.java
$ gcj -g -o chello chello.o hello.o
$ ./chello
not o.k.
This works on Linux. With some debugging it seems that after the ffi_call
in java/lang/reflect/natMethod.cc:439
the variable result is
(gdb) p *result
4ドル = {z = 0 '000円', b = 0 '000円', c = 0, s = 0, i = 1, j = 4294967296,
f = 1.40129846e-45, d = 2.1219957909652723e-314, l = 0x1}
Seems, that the 1 is on the wrong bit position here.
No idea, how i could correct that. The best thing would be, if
libffi/src/sparc/v8.S did the right thing.
Or we have to change the value in src/sparc/ffi.c
afterwards, but do we know, if the return type is boolean here?
Otherwise the change has to be made in a higher hierarchy.
Can anybody confirm this, please?
--
The early bird catches the worm. If you want something else for
breakfast, get up later.
More information about the Java
mailing list