On Mon, 8 Jun 2026 17:23:08 GMT, Frederic Parain <[email protected]> wrote:

>> Here's a patch adding argument validation to the factories for the special 
>> arrays.
>> It also aligns the semantic of these factories with other ways to create 
>> arrays with respect to the initialization state of the element type.
>> Some compiler tests needed adjustments because of the new code shape of the 
>> factories.
>> 
>> Thank you.
>> 
>> ---------
>> - [X] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Frederic Parain has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fixes

Changes requested by [email protected] (no known OpenJDK username).

src/java.base/share/classes/jdk/internal/value/ValueClass.java line 93:

> 91:         }
> 92:         if (length < 0) {
> 93:             throw new IllegalArgumentException("Array length is 
> negative");

There is an exact exception for this (also thrown by 
[`java.lang.reflect.Array::newInstance`]):
Suggestion:

            throw new NegativeArraySizeException(Integer.toString(length));


[`java.lang.reflect.Array::newInstance`]: 
https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/lang/reflect/Array.html#newInstance(java.lang.Class,int)

-------------

PR Review: 
https://git.openjdk.org/valhalla/pull/2435#pullrequestreview-4458681414
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2435#discussion_r3380712866

Reply via email to