-
Notifications
You must be signed in to change notification settings - Fork 61
8298727: Trees.getPath may crash for unnamed package #31
Conversation
👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into |
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.
looks sensible
@lahodaj This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 6 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Thanks for the review, Vicente! |
/integrate |
Going to push as commit 22a6b59.
Your commit was automatically rebased without conflicts. |
Considering an empty
package-info.java
file is normally accepted by javac (as apackage-info
for the unnamed module). But, ifTrees.getPath
is used on the unnamed package, a NPE occurs:The reason is that
Env.tree
is initialized to the package clause inEnter.visitTopLevel
, but when the package clause is missing,Env.tree
isnull
, leading to the error above.The proposed fix is to set
Env.tree
to the top-level tree in this case, to keep it non-null. As the emptypackage-info
can be compiled, it seems reasonable for the model to work on is as well, so a non-null tree needs to be set, and there's no other tree that could be used, I believe.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk20 pull/31/head:pull/31
$ git checkout pull/31
Update a local copy of the PR:
$ git checkout pull/31
$ git pull https://git.openjdk.org/jdk20 pull/31/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 31
View PR using the GUI difftool:
$ git pr show -t 31
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk20/pull/31.diff