Skip to content

8304883: Record Deconstruction causes bytecode error #13192

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

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Mar 27, 2023

Originally, we used to support cases like:
case null, String s when s.isEmpty() -> <expression>
where s could be null inside the expression, but the guard was only evaluated when s != null. This was implemented by augmenting the guard with s == null || <original-guard>.

This feature has been dropped since then.

Also note that in other cases, like:

record R(Object o) {}
Object o = new R(null);
switch (o) {
    case R(var v) when v.toString().isEmpty() -> {}
}

We always expected a NPE on dereferencing the binding with value null (v in this case) in guard.

But, the code to implement the case null, <binding> remained in javac, and is causing problems, because, while the user cannot write case null, <binding> anymore, internally the desugaring sometimes generates that (when factoring out common prefixes). And the original code will still augment the guards to <binding> == null || <guard>, which causes the variables that are assigned in the guard to not being definitely assigned after the augmented guard.

The proposal is to simply remove the code that adds <binding> == null || <guard>, as there's no case where we would skip guards for null bindings anymore.


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

Issue

  • JDK-8304883: Record Deconstruction causes bytecode error

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13192

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 27, 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 rfr Pull request is ready for review label Mar 27, 2023
@openjdk
Copy link

openjdk bot commented Mar 27, 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 Mar 27, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 27, 2023

Webrevs

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.

lgtm

@@ -534,19 +534,6 @@ private void handleSwitch(JCTree tree,
JCExpression test = (JCExpression) this.<JCTree>translate(label.pat);
if (label.guard != null) {
JCExpression guard = translate(label.guard);
if (hasJoinedNull) {
JCPattern pattern = label.pat;
while (pattern instanceof JCParenthesizedPattern parenthesized) {
Copy link
Contributor

Choose a reason for hiding this comment

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

side: this idiom seems to be useful, currently used in a couple of places in Check, could it make sense to extract it into a method?

@openjdk
Copy link

openjdk bot commented Mar 27, 2023

@lahodaj this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8304883
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Mar 27, 2023
@openjdk
Copy link

openjdk bot commented Mar 28, 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:

8304883: Record Deconstruction causes bytecode error

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

  • b062b1b: 8304743: Compile_lock and SystemDictionary updates
  • df819cf: 8304945: StringBuilder and StringBuffer should implement Appendable explicitly
  • 312bbe7: 8305485: Problemlist runtime/Thread/TestAlwaysPreTouchStacks.java
  • 50e31e0: 8305442: (bf) Direct and view implementations of CharBuffer.toString(int, int) do not need to catch SIOBE
  • 85e3974: 8304014: Convert test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java to junit
  • 40aea04: 8278268: (ch) InputStream returned by Channels.newInputStream should have fast path for FileChannel targets
  • 9b9b5a7: 8302323: Add repeat methods to StringBuilder/StringBuffer
  • dd7ca75: 8305478: [REDO] disable gtest/NMTGtests.java sub-tests failing due to JDK-8305414
  • f9827ad: 8288109: HttpExchangeImpl.setAttribute does not allow null value after JDK-8266897
  • 6010de0: 8305417: disable gtest/NMTGtests.java sub-tests failing due to JDK-8305414
  • ... and 78 more: https://git.openjdk.org/jdk/compare/3c4cd50e3cef5905d6c5dacddd6759e118bc50ca...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 merge-conflict Pull request has merge conflict with target branch labels Mar 28, 2023
@lahodaj
Copy link
Contributor Author

lahodaj commented Apr 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Apr 5, 2023

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

  • 0e0c022: 8305356: Fix ignored bad CompileCommands in tests
  • b659c35: 8068824: Exception thrown in JTableHeader after clicking on popupmenu opened with right-click on header
  • 83a924a: 8304042: C2 SuperWord: schedule must remove packs with cyclic dependencies
  • 0ec3d2e: 7124527: [macosx] SwingSet2, label is not read by VoiceOver when focus is on textfield for Internalframe and Table demo.
  • ed9592c: 8305113: (tz) Update Timezone Data to 2023c
  • 15fa78e: 8305237: CompilerDirectives DCmds permissions correction
  • 7cf24d1: 8305400: ISO 4217 Amendment 175 Update
  • a324fa2: 8225641: Calendar.roll(int field) does not work correctly for WEEK_OF_YEAR
  • 3399fbf: 8305602: ProblemList java/lang/invoke/lambda/LogGeneratedClassesTest.java
  • 94a05e0: 8305599: (fc) Temporarily problem-list java/nio/channels/{AsyncCloseAndInterrupt.java, FileChannel/Transfer.java}
  • ... and 109 more: https://git.openjdk.org/jdk/compare/3c4cd50e3cef5905d6c5dacddd6759e118bc50ca...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 5, 2023
@openjdk openjdk bot closed this Apr 5, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 5, 2023
@openjdk
Copy link

openjdk bot commented Apr 5, 2023

@lahodaj Pushed as commit 2aec910.

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

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