On Thu, 20 Aug 2026 07:53:32 GMT, Johan Sjölen <[email protected]> wrote:
>> When creating a new array of type T, the type T should not be initialized. >> This is the case for all types (classes and value classes). The reason that >> this code was added is probably because in a previous Valhalla model, the VM >> filled in a default value for each flattened array element, which >> necessitated the initialization of the class. >> >> --------- >> - [X] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Johan Sjölen has updated the pull request incrementally with two additional > commits since the last revision: > > - Merge remote-tracking branch 'jdksjolen/no-init' into no-init > - Revert documentation changes Thank you for the updates. The change looks good to me. As for the previous discussion in this PR, I would have preferred an explicit `null` check for the `componentType` param, even in release builds because similar checks are already there for the other 2 parameters of this method. For example: jdk.internal.misc.Unsafe.getUnsafe().newSpecialArray(Integer.class, -2, 3); leads to: Exception in thread "main" java.lang.IllegalArgumentException: Array length is negative at java.base/jdk.internal.misc.Unsafe.newSpecialArray(Native Method) at Foo.main(Foo.java:3) and jdk.internal.misc.Unsafe.getUnsafe().newSpecialArray(Integer.class, 2, 42); leads to Exception in thread "main" java.lang.IllegalArgumentException: Invalid layout kind at java.base/jdk.internal.misc.Unsafe.newSpecialArray(Native Method) at Foo.main(Foo.java:3) Some other methods in `jdk.internal.misc.Unsafe` already have null checks for the incoming parameters, so there is some precedence. But the `null` checking for `componentType` can be discussed and addressed (if necessary) in a separate PR. ------------- Marked as reviewed by jpai (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/32193#pullrequestreview-4980598000
