On Fri, 12 Sep 2025 11:28:41 GMT, Jaikiran Pai <[email protected]> wrote:

>> Chen Liang has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Update NPE per roger review
>
> Hello Chen, I had a look at the changes, but I'm missing some broader context 
> of this change.
> 
> The JBS issue and the PR description states that this PR is in preparation 
> (to upcoming additional work?) to support better `NullPointerException` 
> exception messages when some code uses `Objects.requireNonNull()`. It also 
> talks about a `java.lang.runtime.Checks::nullCheck` method, but there's no 
> such `java.lang.runtime.Checks` class in mainline and it appears to be a 
> proposed class in Valhalla project 
> (https://bugs.openjdk.org/browse/JDK-8357936). But there too it's 
> non-existent for now. So I'll leave out the `Checks` class from this 
> discussion.
> 
> If this change were to be integrated into mainline, would there be any change 
> to NullPointerException exception messages in any code paths? If not, then 
> would it better to do these changes along with the `Objects.requireNonNull()` 
> change itself, as part of https://bugs.openjdk.org/browse/JDK-8233268? In 
> JDK-8233268, there's also a comment from Goetz proposing how the new 
> exception message should look like. If the current changes were to be done, 
> would it allow for that proposal to be implemented?
> 
> I did have a brief look at the new jtreg test cases in this PR, but it wasn't 
> immediately clear to me which APIs would start seeing this new proposed 
> exception messages.

Hi @jaikiran, this is currently neutral to mainline. I split the actual 
Objects.rNN changes because they have to go through CSR reviews. The actual 
change to hook it up was removed in 
https://github.com/openjdk/jdk/pull/26600/commits/39c2d16fa98276319d18cf9334e1e9c794e56779.

The message is not the same as what Goetz Lindenmaier proposed, in part because 
the information about the source of the exception is already obvious in the 
stack traces (top level is always the null check API). I decided to only 
include which slot had null instead.

In the test suite, the new API to see the proposed new exception messages would 
be `NullCheckAPITest::nullCheck`. This demonstrates the flexibility of this new 
system I added.

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

PR Comment: https://git.openjdk.org/jdk/pull/26600#issuecomment-3286532403

Reply via email to