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

Invalid lambda in annotation causes NPE in Lint.augment

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 10
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b12

      Description

      The following ill-formed input crashes javac when annotation processing is enabled.

      === T.java
      @interface A {
        Class<?> value();
      }

      @A(value = x -> x)
      class T {}
      === P.java
      import java.util.Set;
      import javax.annotation.processing.AbstractProcessor;
      import javax.annotation.processing.RoundEnvironment;
      import javax.annotation.processing.SupportedAnnotationTypes;
      import javax.lang.model.element.TypeElement;

      @SupportedAnnotationTypes("*")
      public class P extends AbstractProcessor {
        @Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
          return false;
        }
      }
      ===

      $ javac P.java
      $ javac -fullversion -processor P T.java
      javac full version "9-ea+172"
      An exception has occurred in the compiler (9-ea). 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.code.Lint.augment(Lint.java:75)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1128)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:950)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:723)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:742)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2477)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1801)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2543)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1801)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:693)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.getAnnotationClassValue(Annotate.java:603)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotationValue(Annotate.java:574)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotationNameValuePair(Annotate.java:509)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotationValues(Annotate.java:474)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotation(Annotate.java:408)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.annotateNow(Annotate.java:334)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:260)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:184)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:137)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:150)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterDone(JavaCompiler.java:1726)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1054)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:923)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:55)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:41)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: