[jdk17] RFR: 8269697: JNI_GetPrimitiveArrayCritical() should not accept object array
David Holmes
david.holmes at oracle.com
Thu Jul 1 05:00:48 UTC 2021
On 1/07/2021 2:41 pm, David Holmes wrote:
> Hi Zhengyu,
>
> On 1/07/2021 11:24 am, David Holmes wrote:
>> On 1/07/2021 6:17 am, Zhengyu Gu 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).
>>
>> JNI does not in general perform parameter validation. This is a
>> deliberate design choice with JNI. Use of -Xcheck:jni should detect
>> and repport incorrect usage.
>
> Sorry I misunderstood the nature of the proposed fix.
>
>>> 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!
>
> Crashing if passed the wrong type of array is perfectly fine per JNI
> specification "Reporting Errors" section [1].
>
> [1].
> https://docs.oracle.com/en/java/javase/16/docs/specs/jni/design.html#reporting-programming-errors
>
>
> I'll see if I can dig up why the code does what it does.
No this is basically "day one" code from 1997.
David
> Thanks,
> David
> -----
>
>>>
>>> -------------
>>>
>>> Commit messages:
>>> - v0
>>>
>>> Changes: https://git.openjdk.java.net/jdk17/pull/185/files
>>> Webrev: https://webrevs.openjdk.java.net/?repo=jdk17&pr=185&range=00
>>> Issue: https://bugs.openjdk.java.net/browse/JDK-8269697
>>> Stats: 7 lines in 1 file changed: 0 ins; 5 del; 2 mod
>>> Patch: https://git.openjdk.java.net/jdk17/pull/185.diff
>>> Fetch: git fetch https://git.openjdk.java.net/jdk17
>>> pull/185/head:pull/185
>>>
>>> PR: https://git.openjdk.java.net/jdk17/pull/185
>>>
More information about the hotspot-dev
mailing list