On Tue, 20 Oct 2026 17:17:59 GMT, Chen Liang <[email protected]> wrote:

> The Objects.requireIdentity NPEs do not have specified message for all three 
> overloads. Therefore it is not the equivalent for the rNN calls when preview 
> features are disabled.
> 
> Maybe we can later make the String version reuse the static message for the 
> NPE, and convert the Supplier version to a function version. But that's a 
> separate effort.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/java.base/share/classes/java/util/Objects.java line 253:

> 251:      * parameter represents a value object when preview features are 
> enabled.
> 252:      * All objects are identity objects when preview features are 
> disabled;
> 253:      * consequently, this method simply performs a null check when 
> preview

Hello Chen, I think it would be more precise to use the wording suggested in 
the JBS issue's comment, i.e.:

-     * consequently, this method behaves the same as {@link 
#requireNonNull(Object, String)
+     * consequently, this method behaves the same as {@link 
#requireNonNull(Object)

That then clearly specifies that a `NullPointerException` gets thrown. The 
current proposed wording isn't precise in that regard.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33477#discussion_r4625703530

Reply via email to