Fix for the env->klass field value in _Jv_JNIMethod::call

Ivan Dubrov wfragg@gmail.com
Sun Jul 30 03:21:00 GMT 2006


Hello,

While debugging the issue with the Subclipse not working under the GCJ
(look at the message
http://svn.haxx.se/subusers/archive-2006-07/0210.shtml for example) I
found the following problem. When native method is called, the
env->klass value is always NULL. It looks like that JNIEnv is reused in
the "_Jv_GetJNIEnvNewFrame" function and the env->klass value is not
updated during the call.

So, if some native method calls env->FindClass function, the
_Jv_JNI_FindClass function uses system classloader for loading the
required class (since env->klass is NULL) instead of using the
classloader of the class that defines this native method!

Perhaps, it is OK in most cases, except the cases with complex
classloaders logic. The Eclipse is the example of an application with
such logic. When the Subclipse native method (getAdminDirectoryName)
calls FindClass("org.tigris.subversion.javahl.SVNClient"), the system
classloader is used (instead of the classloader that loaded the defining
class, the SVNClient class itself). And since this class is available
only through the chain of Eclipse classloaders and not available through
the system classloader, the FindClass fails - giving the exception
described in the email above.

I've attached a patch that solves the problem with the Subclipse. It
simply updates the env->klass value just before making the ffi call.


P.S.

Steps to reproduce behavior:

1. Install gcj-4.1.1.
2. Run Eclipse with  -vm /path/to/gij
3. Install Subclipse extension (http://subclipse.tigris.org).
4. Open Windows->Preferences dialog, then open Team->SVN tab. The
Eclipse shows error message.

-- 
WBR,
Ivan S. Dubrov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jni_call_klass_fix.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20060730/7a2bfe27/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20060730/7a2bfe27/attachment.sig>


More information about the Java-patches mailing list