JNI on ARM/XScale
Jari Korva
jpkorva@iki.fi
Wed Oct 6 10:57:00 GMT 2004
On 2004年9月30日, Bryce McKinlay wrote:
> Hmm, so if you printf() lib_name immediately before and after the
> JvSynchronize(), it prints the correct value before the call and
> corrupted afterwards? If so, that sounds like a C++ compiler bug, as a
> value on the stack is somehow being overwritten.
>> You could try building natRuntime.cc with -O0 to confirm this theory.
Thanks again! I removed -O2 from libjava/Makefile, touched natRuntime.cc
and ran make again. Then I rebuild my JNI-HelloWorld - and it really
worked!
I also tried printfs instead of debugger on -O2 optimized binary. That
way, it seems that the value is corrupted already before JvSynchronize.
The trace and modified source are below (the most bizarre thing is that it
jumps directly from trace 3-1 to 4).
...
JKO DEBUG 3-1: libhello
JKO DEBUG 3-2: libhello
JKO DEBUG 3-3: libhello
JKO DEBUG 3-1: libhello
JKO DEBUG 4:
...
try
{
for (int i = 0; i < 10; ++i)
{
printf("JKO DEBUG 3-1: %s\n", lib_name);
jclass klass = t->classAt(i);
printf("JKO DEBUG 3-2: %s\n", lib_name);
if (klass != NULL)
{
printf("JKO DEBUG 3-2-1: %s\n", lib_name);
ClassLoader *loader = klass->getClassLoaderInternal();
printf("JKO DEBUG 3-2-2: %s\n", lib_name);
if (loader != NULL && loader != sys)
{
look = loader;
break;
}
}
printf("JKO DEBUG 3-3: %s\n", lib_name);
}
}
catch (::java::lang::ArrayIndexOutOfBoundsException *e)
{
}
printf("JKO DEBUG 4: %s\n", lib_name);
- Jari
More information about the Java
mailing list