This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Bug in JNI RegisterNatives?
- From: Juerg Lehni <juerg at scratchdisk dot com>
- To: java at gcc dot gnu dot org
- Date: Mon, 29 May 2006 22:37:03 +0200
- Subject: Bug in JNI RegisterNatives?
I believe I discovered a rather serious bug in GCJ's implementation
of JNI RegisterNatives.
I have two classes that both define a native method with the same
name and signature.
From looking at jni.cc it seems that GCJ uses a global hash table
(static JNINativeMethod *nathash) for native method lookup in which
it only uses the method's name and signature, but not the class name.
The result is that for any of these native methods that are defined
in more than one class, only the method first registered is called
regardless of the class in use.
The result is that native methods are called on wrong classes and as
they assume the passed jobject to be of a certain class, they crash.
This should not be too hard to fix. One could for example use the
class name plus the mehtod name instead of only the method name when
storing native methods in nathash.
But as I am still new to GCJ, I am not sure that I am proberly
analyzing what is going on.
Jürg