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

Vicente Romero vromero at openjdk.java.net
Mon Dec 7 19:47:17 UTC 2020

On Mon, 16 Nov 2020 10:32:00 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

looks sensible, accepted with minor comment

test/langtools/tools/javac/lambda/LambdaConv30.java line 2:

> 1: /*
> 2:  * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.

nit: the copy year should be 2020 only


Marked as reviewed by vromero (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1221

More information about the compiler-dev mailing list