[jdk17] RFR: 8269697: JNI_GetPrimitiveArrayCritical() should not accept object array
Kim Barrett
kbarrett at openjdk.java.net
Thu Jul 1 00:00:00 UTC 2021
On Wed, 30 Jun 2021 20:11:17 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:
> GetPrimitiveArrayCritical() is supposed to only be used with primitive array types, but nothing prevents current implementation from accepting object arrays (please see attached test case in bug).
>
> My purposed fix is not very friendly, it crashes JVM if a none primitive array is passed in, but I am sure what to expect in this scenario.
>
> Specification people, please comment. Thanks!
Changes requested by kbarrett (Reviewer).
src/hotspot/share/prims/jni.cpp line 2825:
> 2823: }
> 2824: oop a = lock_gc_or_pin_object(thread, array);
> 2825: guarantee(a->is_typeArray(), "Primitive array only");
I think an assert here is more usual. This is JNI - we don't make guarantees (pun slightly intentional). If you want error reporting, use -Xcheck:jni; the appropriate check and reporting is already there.
-------------
PR: https://git.openjdk.java.net/jdk17/pull/185
More information about the hotspot-dev
mailing list