RFR(xs): 8205141: runtime/exceptionMsgs/ArrayStoreException/ArrayStoreExceptionTest.java failed with "assert(k->is_objArray_klass()) failed: cast to ObjArrayKlass"

David Holmes david.holmes at oracle.com
Tue Jun 19 07:32:33 UTC 2018


Hi Thomas,

On 19/06/2018 5:26 PM, Thomas Stüfe wrote:
> Hi all,
> 
> may I have reviews for this fix please:
> 
> https://bugs.openjdk.java.net/browse/JDK-8205141
> http://cr.openjdk.java.net/~stuefe/webrevs/8205141-ArrayStoreExceptionTest-fails-with-assert/webrev.00/webrev/
> 
> Goetz' new ArrayStoreExceptionTest uncovered a problem if the caller
> erroneously feeds an jobject as jobjectArray parameter to
> jni_SetObjectArrayElement.
> 
> The current behavior is to randomly either return a misleading
> ArrayIndexOOBE, or to assert (debug) or to overwrite some memory
> (release) and potentially crash.
> 
> I know that feeding an jobject as jobjectArray is of course all wrong
> and UB I still think it makes in this case sense to catch that and
> throw a correct ArrayStoreException instead of the current behavior.

Sorry but I disagree. JNI deliberately does not perform this kind of 
input parameter checking for performance reasons. It is up to the 
programmer to always pass correctly typed arguments.

https://docs.oracle.com/javase/10/docs/specs/jni/design.html#reporting-programming-errors

If we were to check this then it would be an IllegalArgumentException 
IMO anyway. But we don't check it.

Thanks,
David
-----

> Now, SetObjectArrayElement will throw:
> 
> - "xxx is not an array" for types which are not even an array
> - "xxx is not an object array" for primitive arrays.
> 
> Thank you,
> 
> Thomas
> 


More information about the hotspot-runtime-dev mailing list