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

javac crashes with annotation element of type Class, default void.class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • specification
    • None
    • generic
    • generic, solaris_8

      The following source file:

      package open;

      import java.lang.annotation.*;
      import static java.lang.annotation.ElementType.*;
      import static java.lang.annotation.RetentionPolicy.*;

      @Documented @Inherited @Target(TYPE) @Retention(RUNTIME)
      public @interface NotificationType {
          String value(); // e.g. "my.notif.type"
          Class userDataClass() default void.class; // e.g. MemoryNotifInfo.class
      }

      crashes the current compiler (pre-b46):

      javac -source 1.5 NotificationType.java

      An exception has occurred in the compiler (1.5.0-internal). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) 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.code.Types.erasure(Types.java:1722)
      at com.sun.tools.javac.code.Symbol$ClassSymbol.erasure(Symbol.java:561)
      at com.sun.tools.javac.code.Attribute$Class.makeClassType(Attribute.java:61)
      at com.sun.tools.javac.code.Attribute$Class.<init>(Attribute.java:57)
      at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:195)
      at com.sun.tools.javac.comp.MemberEnter.enterDefaultValue(MemberEnter.java:721)
      at com.sun.tools.javac.comp.MemberEnter.access$400(MemberEnter.java:39)
      at com.sun.tools.javac.comp.MemberEnter$6.enterAnnotation(MemberEnter.java:709)
      at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:92)
      at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:82)
      at com.sun.tools.javac.comp.Enter.main(Enter.java:394)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:382)
      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)

      The code compiles if void.class is changed into Void.class.

            jjb Josh Bloch (Inactive)
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: