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
Conversation
/contributor bsrbnd |
|
@lahodaj Syntax:
|
Webrevs
|
/contributor add bsrbnd |
@lahodaj |
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() {
};
};
} |
looks sensible, accepted with minor comment
@@ -0,0 +1,54 @@ | |||
/* | |||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. |
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.
nit: the copy year should be 2020 only
@lahodaj This change now passes all automated pre-integration checks. 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 431 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.
|
/integrate |
@lahodaj Since your change was applied there have been 435 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit bd22aa5. |
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 givenClassSymbol
, but it has not yet been added into thelocalClassDefs
. The proposed solution is to re-order the tasks done for JCNewClass, and call the super implementation sooner. This will enter theClassSymbol
and corresponding AST node intolocalClassDefs
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 clearlambdaTranslationMap
before processing the anonymous class body.Progress
Issue
Reviewers
Contributors
<bsrbnd@openjdk.org>
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1221/head:pull/1221
$ git checkout pull/1221