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

Null pointer from javac when compile uncompilable java code with annotations

XMLWordPrintable

    • other
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_72"
      Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      All OS
      tested on mac, windows, debian

      A DESCRIPTION OF THE PROBLEM :
      Lets try to compile provided java code. Code is uncompilable, A annotations should be wrapped by an array array. But javac process crashes with nullpointer and do not show proper error message.

      I have found same bug - JDK-8145377. Maintainer has closed it as "could not reproduce". I am not jdk member, so I do not have and account to reopen it. I provide you reproduce steps. So please reopen it (or you can simplify your process to obtain jira account, so I can do it myself ;))

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) try to compile provided java class
      -> compilation ends up with nullpointer

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      javac fails to compile but without nullpointer and shows proper error message
      ACTUAL -
      javac crash

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
       com.sun.tools.javac.comp.Check$1AnnotationValidator.visitAnnotation(Check.java:2658)
      at com.sun.tools.javac.tree.JCTree$JCAnnotation.accept(JCTree.java:2317)
      at com.sun.tools.javac.comp.Check.validateAnnotationTree(Check.java:2663)
      at com.sun.tools.javac.comp.Check.validateAnnotation(Check.java:2730)
      at com.sun.tools.javac.comp.Check.validateAnnotations(Check.java:2717)
      at com.sun.tools.javac.comp.MemberEnter$6.run(MemberEnter.java:891)
      at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:155)
      at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
      at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
      at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
      at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
      at com.sun.tools.javac.main.Main.compile(Main.java:523)
      at com.sun.tools.javac.main.Main.compile(Main.java:381)
      at com.sun.tools.javac.main.Main.compile(Main.java:370)
      at com.sun.tools.javac.main.Main.compile(Main.java:361)
      at com.sun.tools.javac.Main.compile(Main.java:74)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      @B(
          @A,
          @A
      )
      public class Null4JDK {

      }

      @interface B {
          public abstract A[] endpoints() default {};
      }

      @interface A {

      }

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

            aefimov Aleksej Efimov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: