-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8314226: Series of colon-style fallthrough switch cases with guards compiled incorrectly #15532
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
Conversation
👋 Welcome back abimpoudis! A progress list of the required criteria for merging this PR into |
e7a8574
to
c236a21
Compare
…ompiled incorrectly
c236a21
to
09db2c7
Compare
Webrevs
|
So, as we discussed offline, type tests are normally enforced in the switch bootstrap. The first time we hit the test, we know we have some object and that the first label expects an Integer, so we test for that. But if the This would allow us to keep the generated code as is, and avoid introducing coupling between cases in the generated code. |
Btw, looking at the comment in SwitchBootstraps::createRepeatIndexSwitch, it seems that's already the case:
|
Also, in the original test here: It seems to me that the problem is slightly different - e.g. the client is passing a String, but the
How can javac go ahead with this case, considering that the provided string (in the original test) is empty? I wonder if the real issue is that there is no real |
To be clear, IMHO the generated code should be:
|
I think you are right @mcimadamore. We do not need to generate the extraneous condition in the |
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.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.
Looks good!
@biboudis 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 160 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. 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 (@mcimadamore, @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 |
/integrate |
I think I'd like to ask for some more tests. Especially:
instead of
|
Thank you Jan. Does |
Thank you @lahodaj for the improvement. This is extremely elegant and reduces the code size!!! |
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
/sponsor |
@vicente-romero-oracle The PR has been updated since the change author (@biboudis) issued the |
/integrate |
/sponsor |
Going to push as commit 3b0a6d2.
Your commit was automatically rebased without conflicts. |
@vicente-romero-oracle @biboudis Pushed as commit 3b0a6d2. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
/backport jdk21u |
@biboudis the backport was successfully created on the branch biboudis-backport-3b0a6d2a in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:
|
The
switch
structure is translated inhandleSwitch
where we rewrite pattern matching switches. In some occasions a switch has multiple cases with multiple patterns where the n-th case does not complete normally and falls through to the n+1-st case:This PR addresses that by translating the second case correctly and also replicates the body of the latter to the former (which we can do because no bindings are introduced in either statement blocks by the definition of unnamed variables.).
Previously the code was translated into:
This PR adjusts the translation into:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15532/head:pull/15532
$ git checkout pull/15532
Update a local copy of the PR:
$ git checkout pull/15532
$ git pull https://git.openjdk.org/jdk.git pull/15532/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15532
View PR using the GUI difftool:
$ git pr show -t 15532
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15532.diff
Webrev
Link to Webrev Comment