RFR: 8229862: NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570) [v2]
Jan Lahoda
jlahoda at openjdk.java.net
Wed Dec 9 13:40:54 UTC 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.
Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
Correcting copyright year.
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/1221/files
- new: https://git.openjdk.java.net/jdk/pull/1221/files/288dac25..0f8415e1
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=1221&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=1221&range=00-01
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/1221.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/1221/head:pull/1221
PR: https://git.openjdk.java.net/jdk/pull/1221
More information about the compiler-dev
mailing list