JDK-8168480 : Speculative attribution of lambda causes NPE in Flow
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-10-21
  • Updated: 2018-10-10
  • Resolved: 2016-10-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b142Fixed
Related Reports
Duplicate :  
Relates :  
Description
The following program crashes javac:

abstract class Test {
  abstract void f(Runnable r);

  private void g() {
    f(
        () ->
            new Runnable() {
              public void run() {
                switch (42) {
                  default:
                    break;
                }
              }
            }.run());
  }
}

java.lang.AssertionError
        at com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitMethodDef(Flow.java:524)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:836)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitClassDef(Flow.java:494)
        at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:744)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitNewClass(Flow.java:721)
        at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1653)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.tree.TreeScanner.visitSelect(TreeScanner.java:267)
        at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2069)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitApply(Flow.java:713)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1598)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.scanStat(Flow.java:452)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitLambda(Flow.java:737)
        at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1771)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:404)
        at com.sun.tools.javac.comp.Flow$AliveAnalyzer.analyzeTree(Flow.java:761)
        at com.sun.tools.javac.comp.Flow.analyzeLambda(Flow.java:227)
        at com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:429)
        at com.sun.tools.javac.comp.ArgumentAttr.lambda$visitLambda$3(ArgumentAttr.java:279)
        at com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:228)
        at com.sun.tools.javac.comp.ArgumentAttr.visitLambda(ArgumentAttr.java:277)
        at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1771)
        at com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:178)
        at com.sun.tools.javac.comp.Attr$MethodAttrInfo.attr(Attr.java:542)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:632)
        at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:728)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1871)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1598)
        at com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:494)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:632)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:678)
        at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1647)
        at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1416)
        at com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:494)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:632)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:701)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:720)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1173)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:984)
        at com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:494)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:632)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:701)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1064)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:836)
        at com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:494)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:632)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:701)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4436)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4343)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4272)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4247)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1232)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:871)
        at com.sun.tools.javac.main.Main.compile(Main.java:254)
        at com.sun.tools.javac.main.Main.compile(Main.java:142)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)