Skip to content
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

8302865: Illegal bytecode for break from if with instanceof pattern matching condition #14517

Closed
wants to merge 3 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jun 16, 2023

Please see the CSR for the exact wording of the specification change:
https://bugs.openjdk.org/browse/JDK-8310016

There are two changes to flow scoping under this PR:

a) for code like:

X: if (!(o instanceof String s)) {
    break X;
}
System.err.println(s);

s won't be in the scope for System.err.println anymore (as that leads to an invalid bytecode anyway). I was experimenting with several possibilities to fix this, and the final proposal is (when we are about to add some bindings to the scope), look for an immediately enclosing labelled statement(s), and there's some, look for a break to this statement(s).

b) for code like:

X: {
         while (!(o instanceof String s)) {
             break X;
         }
         System.err.println(s);
}

javac implements a strict interpretation of the specification, which does not include s in the scope for the System.err.println (due to the break out of the while). The specification is clarified, so that only breaks to the loop are considered (together with breaks to the enclosing labelled statements), so flow scoping handling for loops is adjusted to only consider breaks to the loop.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8310016 to be approved

Issues

  • JDK-8302865: Illegal bytecode for break from if with instanceof pattern matching condition (Bug - P3)
  • JDK-8310016: Illegal bytecode for break from if with instanceof pattern matching condition (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14517/head:pull/14517
$ git checkout pull/14517

Update a local copy of the PR:
$ git checkout pull/14517
$ git pull https://git.openjdk.org/jdk.git pull/14517/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14517

View PR using the GUI difftool:
$ git pr show -t 14517

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14517.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 16, 2023

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 16, 2023
@openjdk
Copy link

openjdk bot commented Jun 16, 2023

@lahodaj The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jun 16, 2023
@lahodaj lahodaj marked this pull request as ready for review June 16, 2023 13:08
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 16, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 16, 2023

Webrevs

@lahodaj
Copy link
Contributor Author

lahodaj commented Jun 16, 2023

/backport jdk21

@openjdk
Copy link

openjdk bot commented Jun 16, 2023

@lahodaj Backport for repo openjdk/jdk21 on branch master was successfully enabled and will be performed once this pull request has been integrated. Further instructions will be provided at that time.

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks sensible

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@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:

8302865: Illegal bytecode for break from if with instanceof pattern matching condition

Reviewed-by: vromero

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 122 new commits pushed to the master branch:

  • e022e87: 8310053: VarHandle and slice handle derived from layout are lacking alignment check
  • 45eaf5e: 8298443: Remove expired flags in JDK 22
  • 28415ad: 8310225: Reduce inclusion of oopMapCache.hpp and generateOopMap.hpp
  • 4c3efb3: 8309034: NoClassDefFoundError when initializing Long$LongCache
  • 1120106: 8310458: Fix build failure caused by JDK-8310049
  • 09174e0: 8310049: Refactor Charset tests to use JUnit
  • 99d2a9a: 8310330: HttpClient: debugging interestOps/readyOps could cause exceptions and smaller cleanup
  • 31b6fd7: 8309258: RISC-V: Add riscv_hwprobe syscall
  • 4a9cc8a: 8309266: C2: assert(final_con == (jlong)final_int) failed: final value should be integer
  • 4e4e586: 8310194: Generational ZGC: Lock-order asserts in JVMTI IterateThroughHeap
  • ... and 112 more: https://git.openjdk.org/jdk/compare/cf9e6353cc6fe9e57a7a9883813d09892e7e7621...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jun 21, 2023
@lahodaj
Copy link
Contributor Author

lahodaj commented Jun 21, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

Going to push as commit a15db1a.
Since your change was applied there have been 127 commits pushed to the master branch:

  • 67fbd87: 8310143: RandomCommandsTest fails due to unexpected VM exit code after JDK-8282797
  • 9eed049: 8310321: make JDKOPT_CHECK_CODESIGN_PARAMS more verbose
  • 3faba07: 8307145: windowsaccessbridge.dll erroneously includes private methods in its C API
  • 886ac1c: 8308606: C2 SuperWord: remove alignment checks when not required
  • 47d00a4: 8310265: (process) jspawnhelper should not use argv[0]
  • e022e87: 8310053: VarHandle and slice handle derived from layout are lacking alignment check
  • 45eaf5e: 8298443: Remove expired flags in JDK 22
  • 28415ad: 8310225: Reduce inclusion of oopMapCache.hpp and generateOopMap.hpp
  • 4c3efb3: 8309034: NoClassDefFoundError when initializing Long$LongCache
  • 1120106: 8310458: Fix build failure caused by JDK-8310049
  • ... and 117 more: https://git.openjdk.org/jdk/compare/cf9e6353cc6fe9e57a7a9883813d09892e7e7621...master

Your commit was automatically rebased without conflicts.

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

Creating backport for repo openjdk/jdk21 on branch master

/backport openjdk/jdk21 master

@openjdk openjdk bot added integrated Pull request has been integrated and removed backport=openjdk/jdk21:master labels Jun 21, 2023
@openjdk openjdk bot closed this Jun 21, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 21, 2023
@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@lahodaj Pushed as commit a15db1a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@openjdk[bot] @lahodaj the backport was successfully created on the branch lahodaj-backport-a15db1a5 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit a15db1a5 from the openjdk/jdk repository.

The commit being backported was authored by Jan Lahoda on 21 Jun 2023 and was reviewed by Vicente Romero.

Thanks!

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/jdk21:

$ git fetch https://github.com/openjdk-bots/jdk21.git lahodaj-backport-a15db1a5:lahodaj-backport-a15db1a5
$ git checkout lahodaj-backport-a15db1a5
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21.git lahodaj-backport-a15db1a5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants