Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

8268663: Crash when guards contain boolean expression #41

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jun 14, 2021

When Flow analyzes boolean expressions, (un-)initialized are split into (un-)initialized when true and when false. When analyzing guarded patterns, we need to handle these split values. As the only way the case's body/statements can be executed is if the case's pattern matches, we need to use the initialized values when true.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8268663: Crash when guards contain boolean expression

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/41/head:pull/41
$ git checkout pull/41

Update a local copy of the PR:
$ git checkout pull/41
$ git pull https://git.openjdk.java.net/jdk17 pull/41/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 41

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/41.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 14, 2021

👋 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 rfr Pull request is ready for review label Jun 14, 2021
@openjdk
Copy link

openjdk bot commented Jun 14, 2021

@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.java.net label Jun 14, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 14, 2021

Webrevs

String typeGuardIfTrueSwitchStatement(Object o) {
Object o2 = "";
switch (o) {
case Integer i && i == 0 && i < 1 && o2 instanceof String s: o = s + String.valueOf(i); return "true";
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle Jun 14, 2021

Choose a reason for hiding this comment

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

hi, I would recommend adding more tests with || in the condition, and with more than one case in the switch with conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, Vicente. I've added tests with || in d9e902b . One thing to note is that the tests are a bit different when writing something like: case String s && s.isEmpty() || o2 instanceof Number n -> n is not available here, as there is a path on which o2 is not a Number.

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 good

@openjdk
Copy link

openjdk bot commented Jun 14, 2021

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

8268663: Crash when guards contain boolean expression

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

  • c088d09: 8268522: InstanceKlass::can_be_verified_at_dumptime() returns opposite value
  • abe20c1: 8268333: javac crashes when pattern matching switch contains default case which is not last
  • b318535: 8267579: Thread::cooked_allocated_bytes() hits assert(left >= right) failed: avoid underflow
  • fe48ea9: 8268342: java/foreign/channels/TestAsyncSocketChannels.java fails with "IllegalStateException: This segment is already closed"

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 the ready Pull request is ready to be integrated label Jun 14, 2021
@lahodaj
Copy link
Contributor Author

lahodaj commented Jun 15, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Jun 15, 2021

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

  • 4d8b5c7: 8268347: C2: nested locks optimization may create unbalanced monitor enter/exit code
  • 4a6da99: 8268643: SVML lib shouldn't be generated when C2 is absent
  • a5bf5e0: 8266614: update manpage for -Xlog:async
  • f69e2d5: 8267397: AlgorithmId's OID cache is never refreshed
  • ee30159: 8268621: SunJCE provider may throw unexpected NPE for un-initialized AES KW/KWP Ciphers
  • 702e3ff: 8268366: Incorrect calculation of has_fpu_registers in C1 linear scan
  • bca914b: 8268670: yield statements doesn't allow ~ or ! unary operators in expression
  • c088d09: 8268522: InstanceKlass::can_be_verified_at_dumptime() returns opposite value
  • abe20c1: 8268333: javac crashes when pattern matching switch contains default case which is not last
  • b318535: 8267579: Thread::cooked_allocated_bytes() hits assert(left >= right) failed: avoid underflow
  • ... and 1 more: https://git.openjdk.java.net/jdk17/compare/6171ae455288a74c4c3dcec6983515db04bdc360...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jun 15, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 15, 2021
@openjdk
Copy link

openjdk bot commented Jun 15, 2021

@lahodaj Pushed as commit 35d867d.

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

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

Successfully merging this pull request may close these issues.

2 participants