RFR (S): 8022683 : JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
David Simms
david.simms at oracle.com
Fri Aug 16 07:45:42 PDT 2013
Hello all,
Need reviewers on a JDK8 fix for:
http://bugs.sun.com/view_bug.do?bug_id=8022683
Found the following functions need to return NULL as suggested by the
JNI spec
(http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html):
* GetStringChars()
* GetStringUTFChars()
* Get<PrimitiveType>ArrayElements() family of array getters (same
generating macro).
Although the specification suggests OOME may be thrown by certain
functions, the documentation on the aforementioned functions does not
suggest "throws". So they return NULL now without aborting the JVM as
before.
It was assumed the meaning of "isCopy" is undefined given a NULL result,
in keeping with the rest of jni.cpp.
Also discovered allocation.hpp macros missing proper argument bracketing
(e.g. size passed in NEW_C_HEAP_ARRAY_RETURN_NULL()), fixed them up
since I was there (and they caused trouble).
Webrev:
http://cr.openjdk.java.net/~dsimms/8022683/
<http://cr.openjdk.java.net/%7Edsimms/8022683/>
Testing:
Attached "unit test" to bug, naive test program to trigger OOM. It is
not suitable for automated testing. Ideally require hooks into the JVM
to simulate OOM during JNI calls.
Cheers
/David Simms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130816/10567d61/attachment.html
More information about the hotspot-runtime-dev
mailing list