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

8229862: NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570) #1221

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Nov 16, 2020

Based on Bernard's code from:
http://mail.openjdk.java.net/pipermail/compiler-dev/2020-October/015225.html

Capturing anonymous classes inside lambdas may fail to compile, because:
-the captured variables are not detected correctly, because LambdaToMethod...captureLocalClassDefs needs to find the AST node for the given ClassSymbol, but it has not yet been added into the localClassDefs. The proposed solution is to re-order the tasks done for JCNewClass, and call the super implementation sooner. This will enter the ClassSymbol and corresponding AST node into localClassDefs before the capture variables detection.
-inside the anonymous class definition, some references to the captured variables are replaced using a map that maps captured variables for lambdas (lambdaTranslationMap) - but inside the anonymous class, there the captured variables should be mapped using the anonymous class' map/proxies (to fields). The proposed solution is to clear lambdaTranslationMap before processing the anonymous class body.


Progress

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

Issue

  • JDK-8229862: NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570)

Reviewers

Contributors

  • Bernard Blaser <bsrbnd@openjdk.org>

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1221/head:pull/1221
$ git checkout pull/1221

@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Nov 16, 2020

/contributor bsrbnd

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 16, 2020

👋 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 label Nov 16, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Nov 16, 2020

@lahodaj Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

@openjdk
Copy link

@openjdk openjdk bot commented Nov 16, 2020

@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 label Nov 16, 2020
@mlbridge
Copy link

@mlbridge mlbridge bot commented Nov 16, 2020

Webrevs

@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Nov 16, 2020

/contributor add bsrbnd

@openjdk
Copy link

@openjdk openjdk bot commented Nov 16, 2020

@lahodaj
Contributor Bernard Blaser <bsrbnd@openjdk.org> successfully added.

@hltj
Copy link
Contributor

@hltj hltj commented Nov 27, 2020

Great! This fix the issue I have met when I trying to fix another issue (#1479).

My minimal reproducing code is:

class Main {
    static Runnable runnable = () -> {
        String s0 = "hello";

        class Local {
            int i = s0.length();
        }

        Runnable dummy = () -> new Local() {
        };
    };
}

Copy link
Contributor

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

looks sensible, accepted with minor comment

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle Dec 7, 2020

Choose a reason for hiding this comment

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

nit: the copy year should be 2020 only

@openjdk
Copy link

@openjdk openjdk bot commented Dec 7, 2020

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

8229862: NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570)

Co-authored-by: Bernard Blaser <bsrbnd@openjdk.org>
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 431 new commits pushed to the master branch:

  • 0201a33: 8255959: Timeouts in VectorConversion tests
  • d3dddb6: 8256657: Add cross-compiled build for Windows+Arm64 to submit workflow
  • 616b1f1: 8257516: define test group for manual tests
  • 5bdce9b: 8257639: Update usage of "type" terminology in java.lang.Enum & java.lang.Record
  • b4615c6: 8256580: Fault in new grid display
  • df55ecd: 8257794: Zero: assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1) failed: wrong on Linux/x86_32
  • fae7961: 8257884: Re-enable sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java as automatic test
  • 79f1dfb: 8255987: JDI tests fail with com.sun.jdi.ObjectCollectedException
  • 9ce3d80: 8257887: java/foreign/TestSegments.java test fails on 32-bit after JDK-8257186
  • 10da767: 8257847: Tiered should publish MDO data pointer for interpreter after profile start
  • ... and 421 more: https://git.openjdk.java.net/jdk/compare/ac3948930ef2b188401d67f20f730fefe7d15e1e...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 the ready label Dec 7, 2020
@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Dec 9, 2020

/integrate

@openjdk openjdk bot closed this Dec 9, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Dec 9, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Dec 9, 2020

@lahodaj Since your change was applied there have been 435 commits pushed to the master branch:

  • cf62b0a: 8257518: LogCompilation: java.lang.InternalError with JFR turned on
  • 6c69eca: 8257973: UTIL_LOOKUP_PROGS should only find executable files
  • 6eff931: 8256950: Add record attribute support to symbol generator CreateSymbols
  • f148915: 8245107: Use Unified Logging in trace_method_handle_stub()
  • 0201a33: 8255959: Timeouts in VectorConversion tests
  • d3dddb6: 8256657: Add cross-compiled build for Windows+Arm64 to submit workflow
  • 616b1f1: 8257516: define test group for manual tests
  • 5bdce9b: 8257639: Update usage of "type" terminology in java.lang.Enum & java.lang.Record
  • b4615c6: 8256580: Fault in new grid display
  • df55ecd: 8257794: Zero: assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1) failed: wrong on Linux/x86_32
  • ... and 425 more: https://git.openjdk.java.net/jdk/compare/ac3948930ef2b188401d67f20f730fefe7d15e1e...master

Your commit was automatically rebased without conflicts.

Pushed as commit bd22aa5.

💡 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 integrated
3 participants