On Tue, 18 Aug 2026 22:40:56 GMT, David Holmes <[email protected]> wrote:
>> src/java.base/share/classes/jdk/internal/misc/Unsafe.java line 325:
>>
>>> 323: * @return an array whose contents is potentially uninitialized
>>> 324: */
>>> 325: public native Object[] newSpecialArray(Class<?> componentType,
>>
>> Hello Johan, should there be an explicit check for `componentType` being
>> non-null (and document that it expects non-null)? Right now the following
>> call crashes a (release build) JVM:
>>
>>
>> public class Foo {
>> public static void main(final String[] args) throws Exception {
>> jdk.internal.misc.Unsafe.getUnsafe().newSpecialArray(null, 2, 0);
>> }
>> }
>
> Document yes, check no. The onus is on the caller to use Unsafe correctly and
> safely.
Edited the docs.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32193#discussion_r3813987540