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

NPE in Attr.visitVarDef

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 9
    • Fix Version/s: 10
    • Component/s: tools
    • Labels:

      Description

      The following program crashes javac 9-ea+149:

      ===
      import java.util.function.*;
      class Test {
        @interface I { String x(); }
        static <F, T> T apply(T x, Function<F, T> f) { return f.apply(x); }

        @I(x = apply("X", x -> x.toString())) int x;
      }
      ===

      java.lang.NullPointerException
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1110)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:950)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:501)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:639)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:708)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:727)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2454)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1801)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.attr(Attr.java:501)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:639)
              at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:340)
              at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:301)
              at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.access$000(DeferredAttr.java:172)
              at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:741)
              at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:585)
              at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:220)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:589)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:628)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3973)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: