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

[local-methods] NPE with recursive invocation of local method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • repo-amber
    • repo-amber
    • tools
    • generic
    • generic

      Reported in Amber-dev by Jake Wharton:

      The following program causes javac to crash:

      import java.util.List;
      import java.util.function.Predicate;

      interface Node {
        List<Node> getNodes();

        static boolean any(Node root, Predicate<Node> predicate) {
          boolean hasMatch(Node node) {
            if (predicate.test(node)) return true;
            return node.getNodes().stream().anyMatch(n -> hasMatch(n));
          }
          return hasMatch(root);
        }
      }

      with:
      at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570)
      at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:399)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:885)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1851)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1736)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:860)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1814)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1648)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:597)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:632)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:618)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:669)
      at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1080)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1029)
      ...

            vromero Vicente Arturo Romero Zaldivar
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: