-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8364588: Export the NPE backtracking functionality to general null-checking APIs #26600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
8364588: Export the NPE backtracking functionality to general null-checking APIs #26600
Conversation
…ireNonNull-message-hacks
…ireNonNull-message-hacks
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Thanks for the preliminary review. After some thinking, to avoid wasting review cycles, I am pulling the common infrastructure for requireNonNull and Checks::nullCheck into a JDK-internal API, and the changes here are mostly confined to runtime. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VM side seems reasonable. Java side looks a bit clunky but that is up to core-libs folk to evaluate.
General note: if comments start with a capital they should end with a period, and vice-versa. Extended comments should consist of full sentences.
Thanks.
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reading this. A few comments, mostly intended to make this easier to grok for future readers. The actual logic seems fine from a first read.
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
…ireNonNull-message-hacks
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/lang/NullPointerException.java
Outdated
Show resolved
Hide resolved
Co-authored-by: David Holmes <[email protected]>
…dded/jdk into exp/requireNonNull-message-hacks
|
/reviewers 3 reviewer |
@RogerRiggs |
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
/touch |
@liach The pull request is being re-evaluated and the inactivity timeout has been reset. |
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 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 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 39c2d16. 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 |
Can anyone come and review this little enhancement again? I think I have addressed the review comments. |
enum class BacktrackNullSlot : int { | ||
// This NullPointerException is explicitly constructed | ||
NPE_EXPLICIT_CONSTRUCTED = -2, | ||
// There cannot be a NullPointerException at the given BCI | ||
INVALID_BYTECODE_ENCOUNTERED = -1, | ||
// A slot is found | ||
FOUND | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you define an ENUM to capture the negative cases but then you can use any int >= 0 and pretend it is a member of the enum. ?? Is that typical C++ enum usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was from @jdksjolen's suggestion. I emulated how valhalla's LayoutKind is declared.
Provide a general facility for our null check APIs like Objects::requireNonNull or future Checks::nullCheck (void), converting the existing infrastructure to start tracking from a given stack site (depth offset) and a given stack slot (offset value).
This is a necessary prerequisite for https://bugs.openjdk.org/browse/JDK-8233268, which proposes enhanced null messages to
Objects::requireNonNull
.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26600/head:pull/26600
$ git checkout pull/26600
Update a local copy of the PR:
$ git checkout pull/26600
$ git pull https://git.openjdk.org/jdk.git pull/26600/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26600
View PR using the GUI difftool:
$ git pr show -t 26600
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26600.diff
Using Webrev
Link to Webrev Comment