Re: Java_java_lang_VMClass_getDeclaredFields question

Etienne Gagnon <[email protected]> Wed, 19 Jan 2005 00:24:32 -0500
Newsgroups gmane.comp.java.vm.sablevm.devel
Organization UQAM
Message-ID <[email protected]>
Chris Pickett wrote:
> In Java_java_lang_VMClass_getDeclaredFields, how come at label "end:", 
> if you fail to exit the monitor, you return from the function without 
> any errors?

Actually, if releasing the monitor fails, env->throwable will be set to 
the trhown exception.  Note that this JNI code is called from Java.  The 
virtual machine does *always* check for pending exception before 
resuming to normal Java code execution, when returning from a JNI call.

Here's the code that does a JNI call in native.c:
...
     /* do the call */
     ffi_call (method->data.native_method->cif,
               method->data.native_method->code, &result, ptrs);

     /* coming back */
     _svmf_resuming_java (env);

     /* retrieve current frame */
     frame = env->stack.current_frame;
...
     /* if no exception was thrown */
     if (*(env->throwable) == NULL)
...
   return (*(env->throwable) == NULL) ? JNI_OK : JNI_ERR;


So, in this case, the exception will simply propagate to Java code 
normally.  I see no problem.

Etienne
-- 
Etienne M. Gagnon, Ph.D.            http://www.info2.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/

_______________________________________________
SableVM-devel mailing list
[email protected]
http://sablevm.org/lists/control/listinfo/sablevm-devel
signature.asc (application/pgp-signature, 256 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB7e8QjyrJi4rH84gRAvrVAJ4x8Vap54mOk2RjB2SChs4J7wOM8gCfTciD
8MAUV4+yYgHNm5jwee+EYZM=
=dIbR
-----END PGP SIGNATURE-----