This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Error while compiling a class for jni
- To: Thomas Kuhn <t_kuhn at gmx dot de>
- Subject: Re: Error while compiling a class for jni
- From: Tom Tromey <tromey at redhat dot com>
- Date: 20 Aug 2001 17:36:08 -0600
- Cc: java at gcc dot gnu dot org
- References: <200108202111.OAA01395@cygnus.com>
- Reply-To: tromey at redhat dot com
>>>>> "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