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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: repo-amber
    • Fix Version/s: repo-amber
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

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

        Attachments

          Activity

            People

            Assignee:
            sadayapalam Srikanth Adayapalam
            Reporter:
            sadayapalam Srikanth Adayapalam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: