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

javac crash when declare an annotation type illegally

XMLWordPrintable

    • b49
    • generic
    • generic


      ###@###.### 2004-03-11

      J2SE Version (please include all output from java -version flag):
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b40)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b40, mixed mode)

      Does this problem occur on J2SE 1.3.x or 1.4.x? Yes / No (pick one)
        No

      Operating System Configuration Information (be specific):
        Windows 2000 Professional SP2

      Bug Description:

      Attempting to declare an annotation type where it is not legal to do
      so causes javac to emit an error message (as expected) then crash.
      Test program uses an instance initializer to demonstrate this, but
      the same behaviour was observed when placing the declaration within
      a static initializer or method.


      Test Program: IllegalAnnotation.java

          // Start of IllegalAnnotation.java

          class IllegalAnnotation {
              {
                  @interface SomeAnnotation { }
              }
          }

          // End of IllegalAnnotation.java


      Steps to Reproduce (be specific):

      1) Save the file above as IllegalAnnotation.java
      2) javac -source 1.5 IllegalAnnotation.java
      3) Rejoice at the error message then weep at the stack trace:

      IllegalAnnotation.java:3: modifier interface not allowed here
              @interface SomeAnnotation { }
               ^
      An exception has occurred in the compiler (1.5.0-beta2). Please file
      a bug at the Java Developer Connection
       (http://java.sun.com/cgi-bin/bugreport.cgi)
      after checking the Bug Parade for duplicates. Include your program
      and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at
      com.sun.tools.javac.comp.Check.validateAnnotationType(Check.java:1503)
              at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:453)
              at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:256)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:291)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2337)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2270)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2221)
              at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:397)
              at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:438)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:256)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:291)
              at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:307)
              at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:567)
              at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:256)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:291)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2337)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2270)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2221)
              at
      com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:410)
              at com.sun.tools.javac.main.Main.compile(Main.java:586)
              at com.sun.tools.javac.main.Main.compile(Main.java:538)
              at com.sun.tools.javac.Main.compile(Main.java:44)
              at com.sun.tools.javac.Main.main(Main.java:35))

            gafter Neal Gafter (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: