Re: Question on how JNI spec & you (+others?) conform to it.
Etienne Gagnon <[email protected]> Mon, 17 Oct 2005 12:05:27 -0400
| Newsgroups | gmane.comp.java.vm.sablevm.devel |
|---|---|
| Message-ID | <[email protected]> |
Interesting... When Sun publishes a book and calls it "spec", it it not a spec. Yet, I remember some older JNI online spec to be buggy in places where the book was correct (some function prototypes, if I remember correctly). As I said, I'm sure the real spec is "The [proprietary] Source Code" even though Sun will never claim so publicly. :-) As for your example, such program was never meant to be safe. The whole idea of xxxCritical() functions is to disable GC between the Get and the Release. As a consequence, there must be no Call to any JNI function that can potentially cause object allocation between the Get and Release. This rules out the overlapping of xxxCritical() function calls. The book is clearly wrong. [This is my VM implementor view]. If you need overlapping call, simply use the non-critical versions of these functions (e.g. GetPrimitiveArray()), at least for the outer calls. Have fun! Etienne [email protected] wrote: > Turns out this may have been a mistake: from > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4458083 >... > > p1 = env->GetPrimitiveArrayCritical(array1); > if (!p1) { return SOME_ERROR_CODE; /* exception is pending */ } > p2 = env->GetPrimitiveArrayCritical(array2); > if (!p2) { > /* Now what!? > According to the the book it's not safe to call Exception<Stuff> > (because we are in JNI critical section) > According to spec it's not safe to call Release<Stuff>Critical > (because exception is pending) > While we dither with indecision here, the GC, or possibly the entire > Java runtime, may have been suspended */ > } -- 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.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDU8vHjyrJi4rH84gRAo8BAJ9Hlpn89VoqTWwYlcY3gIKPF8/8qgCfQu/j YJY+GvsfB5nrt0Pp2XrBXVA= =yTFk -----END PGP SIGNATURE-----