Error while compiling a class for jni
Tom Tromey
tromey@redhat.com
Mon Aug 20 16:02:00 GMT 2001
>>>>> "Thomas" == Thomas Kuhn <t_kuhn@gmx.de> writes:
Thomas> I just ran into an strage Error. I'm using gcc 3.0. I wrote a
Thomas> java file test.java, this file contains only a single native
Thomas> method testme(int).
I assume you are running into some problem. What is it?
Thomas> nm test.o prints :
Thomas> 00000020 T _ZN4test6testmeEi
This is normal. Here's what is going on:
gcj always generates an ordinary C++-style method call. So, for
instance, if you have code in test.java which calls testme(int), gcj
will emit this as either a call via the vtable (for a method) or as a
call directly to the function named `_ZN4test6testmeEi' (for a final
or static method).
However, this obviously won't work for a JNI method. That is because
the method's name (the underlying symbol in the executable) is
different, and the calling convention is different.
So, `gcj -fjni' makes a stub method. This stub simply calls into the
libgcj JNI code to look up the actual underlying JNI method at
runtime. The function nm is reporting to you is just this stub.
Tom
More information about the Java
mailing list