RFR: JDK-8267041: javac crash when creating lambda with capture inside a switch expression
Vicente Romero
vromero at openjdk.java.net
Thu May 13 15:09:15 UTC 2021
On Thu, 13 May 2021 13:46:13 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Variables declared inside switch expressions used as initializers to fields have the field as their owner. We need to make sure they are captured by `LambdaToMethod` - there were a few places where the checks were missing, leading to a crash later during code generation.
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java line 1356:
> 1354: if (context() != null && lambdaIdentSymbolFilter(tree.sym)) {
> 1355: if (tree.sym.kind == VAR &&
> 1356: (tree.sym.owner.kind == MTH || tree.sym.owner.kind == VAR) &&
just curious: why wasn't this code stressed before? I mean it should be possible to stress it without switch expressions right?
-------------
PR: https://git.openjdk.java.net/jdk/pull/4012
More information about the compiler-dev
mailing list