-
Notifications
You must be signed in to change notification settings - Fork 144
8267610: NPE at at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop #59
Conversation
👋 Welcome back gli! A progress list of the required criteria for merging this PR into |
/issue add 8268748 |
@lgxbslgx |
Webrevs
|
/issue remove 8268748 |
@lgxbslgx |
@lgxbslgx |
Ping for review. |
Thanks for looking into this and sorry for trouble. Looking at the implementation, would it make sense to set the currentValue only after the expression is translated? E.g. something like:
I think the |
@lahodaj thanks for your comment. I have tried your way before submitting this PR. But the compiler didn't work as expected.
So I revised the code like this patch which seems to use unnecessary variable |
Do you have details on what goes wrong when the |
In short: I re-read the code and my current patch seems wrong. I would like to adopt your advice and your patch. Thanks for the clarification. In detailed: I can't find the original change locally now. I try my best to recall the process. The following steps lead me to the wrong direction. First, I might use the following patch. As you can see, I didn't get the new
Then, I look into the failed tests and found that the method
At this time, I mistakenly confirmed that both My patch seems good to solve the bug, but actually the After these analysis, I think my current patch may cause some new regresion because the |
@lahodaj I updated the code by adopting your advice. Considering that I can't accurately recall the potential regression situation, I suggest it should be more than one reviewer to approve this patch before integrating. |
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.
To me, looks good. @vicente-romero-oracle, could you please take a look? Thanks!
@lgxbslgx 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 As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@lahodaj, @vicente-romero-oracle) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
||
List<String> actualCode = getCodeInstructions(code_attribute); | ||
List<String> expectedCode = Arrays.asList( | ||
"aload_1", "instanceof", "ifeq", "aload_1", "checkcast", "astore_2", "aload_2", "instanceof", |
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.
not sure I like this code pattern check, if we change the generated code for whatever reason we will need to revisit this test. Is there other way of testing the same? like executing a code and checking its result(s) or throwing an exception if something unexpected happened?
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.
@vicente-romero-oracle Thanks for your review.
In this test, if the bug is not fixed which means the aload_2
would be aload_1
, the code runs well too.
The aload_1
or aload_2
don't effect the result so that we can't check it by executing it.
There are some similar situations in the past when we want to verify the class files.
These tests would also fail if we change the logic of the code generation.
Another way is that only verify if the aload_2
is at the right place instead of verify all the instruments.
But it also need to be revisited and revised if the logic of the code generation is changed in the future.
It seems a unavoidable issue about verifing the class files.
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.
@vicente-romero-oracle Thanks for your review.
In this test, if the bug is not fixed which means the
aload_2
would beaload_1
, the code runs well too.
Theaload_1
oraload_2
don't effect the result so that we can't check it by executing it.
There are some similar situations in the past when we want to verify the class files.
These tests would also fail if we change the logic of the code generation.Another way is that only verify if the
aload_2
is at the right place instead of verify all the instruments.
But it also need to be revisited and revised if the logic of the code generation is changed in the future.
It seems a unavoidable issue about verifing the class files.
I see, thanks for the clarification
Thanks @lahodaj @vicente-romero-oracle for the review. /integrate |
Going to push as commit 7ab1285.
Your commit was automatically rebased without conflicts. |
Hi all,
Currently, the class TransPatterns sometimes doesn't transform the
pattern variables
andpattern symbols
to the normal variables and symbols, especially the places where the pattern variables are used.The following phases, such as LambdaToMethod, Lower and Gen, may crash or generate some wrong results.
The known issues are JDK-8267610 and JDK-8268748.
JDK-8267610 is an issue that pattern symbol causes the compiler to crash.
During transforming the InstanceOfTree (JCInstanceOf) , the
BindingSymbol
instead of theVarSymbol
is used to make the newJCIdent
andJCBinary
trees. At the phase LambdaToMethod, the compiler can't capture this variable so that the lambda method has uncorrect parameters. So at the phase Gen, the compiler crashes because of NPE.JDK-8268748 is an issue that pattern symbol causes that the compiler generates wrong bytecodes.
When transforming the BindingPatternTree (JCBindingPattern), the
BindingSymbol
is also handled uncorrectly and used to make the newJCIdent
andJCAssign
trees. At the phase Gen, the compiler find the wrong variables, so that the wrong bytecodes are generated.These two issues are similar and influence each other. So I solve them at one patch.
The lines 208-212 are to solve JDK-8267610 with the test
LambdaCannotCapturePatternVariables
.The lines 233-239 are to solve JDK-8268748 with the test
NestedPatternVariablesBytecode
.If lines 208-212 are not included, the test
NestedPatternVariablesBytecode
can't pass.If lines 233-239 are not included, the test
LambdaCannotCapturePatternVariables
can't pass.So I put them together.
Thanks for taking the time to review.
Best Regards,
-- Guoxiong.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/59/head:pull/59
$ git checkout pull/59
Update a local copy of the PR:
$ git checkout pull/59
$ git pull https://git.openjdk.java.net/jdk17 pull/59/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 59
View PR using the GUI difftool:
$ git pr show -t 59
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/59.diff