On Sun, 16 Nov 2025 17:11:35 GMT, Alan Bateman <[email protected]> wrote:
>> Chen Liang has updated the pull request incrementally with three additional
>> commits since the last revision:
>>
>> - Rephrase for parameterTypes contains null
>> - Rename tests to be more specific
>> - Split annotated type new checks to another patch
>
> src/java.base/share/classes/java/lang/Class.java line 2152:
>
>> 2150: * {@code name} and {@code parameterTypes}
>> 2151: * @throws NoSuchMethodException if a matching method is not
>> found, such as
>> 2152: * when {@code parameterTypes} contains {@code null},
>
> It might be clearer to say "or parameterTypes contains a null element" rather
> than "such as when ..."
My impression of this behavior is that no method can have a parameter type
array that contains a `null` value. So claiming there is no matching method for
this scenario probably makes sense?
> Now we have this odd scenario where a null element will provoke an eager NPE
> if flag is true
Sorry, but I fail to see where that happens - I believe if the array has a null
element, `array.clone()` executes successfully, and the NPE is only thrown
after some elements are set accessible. If the array is null, the array
iteration would immediately fail with a NullPointerException just like when
clone is executed. So both `false` and `true` paths would have the same NPE
behavior.
In addition, the other exceptions of this methods are already thrown with side
effects on the elements in the array before the first null value, and the side
effects is not additionally specified. I think we can specify the NPE without
requiring the NPE to be thrown before any side effect has been committed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28336#discussion_r2532159152
PR Review Comment: https://git.openjdk.org/jdk/pull/28336#discussion_r2532158581