Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297336

NPE: FlowAnalyzer.visitApply for nestedClass>method>lambda1>lambda2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 11.0.17
    • tools
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/javac --version
      javac 11.0.17


      A DESCRIPTION OF THE PROBLEM :
      An exception has occurred in the compiler (11.0.17). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1235)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:213)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1468)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:997)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$LambdaFlowAnalyzer.visitLambda(Flow.java:1430)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1827)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:398)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1327)
      at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeLambdaThrownTypes(Flow.java:252)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2615)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1827)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:376)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr$ArgumentType.complete(ArgumentAttr.java:364)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:337)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:323)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
      at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4131)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3924)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3825)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3814)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3564)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2264)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1468)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:501)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:483)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:458)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:875)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:853)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1827)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:807)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:337)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:754)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:601)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:620)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1563)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1733)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1802)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1776)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2654)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3293)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3543)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2651)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2645)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3732)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3612)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2130)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1468)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4694)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4585)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4514)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:951)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4694)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4585)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4514)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4459)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1337)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)


      also seen before NPE:
      java: compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.17, {1}, {2}, {3}, {4}, {5}, {6}, {7}


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile attached source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compiles
      ACTUAL -
      NPE in compiler

      ---------- BEGIN SOURCE ----------

      class CompNpeLambdaReproIndep {
      interface IntProcedure {
      boolean execute(int a);
      }

      static class Outer {
      void foreach(IntProcedure p) {
      }
      }

      interface RunnableWithException<E extends Exception> {
      void run() throws E;
      }

      static <E extends Exception> void propagateAndRun( RunnableWithException<E> rwe) {
      }

      class Nested {
      void method2() {
      Outer map = new Outer();
      map.foreach(intParam -> {
      propagateAndRun(() -> {
      System.out.println("reference outer param " + intParam);
      });
      return true;
      });
      }
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Extract innermost lambda into a method

      FREQUENCY : always


            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: