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

(ann) Documented class may miss itself in its own annotations list

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 5.0
    • core-libs
    • None
    • generic
    • generic



      Name: siR10004 Date: 04/29/2004


      List of annotations of the class 'Documented', returned by 'getDeclaredAnnotations'
      method, may be wrong in some cases.

      To reproduce, compile the following program:
      ----------------------------------------------------------------
      import java.lang.annotation.*;

      public class V {
          public static void main (String[] args) throws Throwable {
              for (int i = 0; i < args.length; i++)
                  probe(args[i]);
          }
          
          static void probe (String fqn) throws Throwable {
              System.out.println("CLASS " + fqn);
              Class c = Class.forName(fqn, false, null);
              Annotation[] alist = c.getDeclaredAnnotations();
              if (alist != null)
                  for (int i = 0; i < alist.length; i++) {
                      Class a = alist[i].annotationType();
                      System.out.println(" Annotation " + a.getName());
                  }
          }
      }
      ----------------------------------------------------------------

      Please note the difference in the annotations lists presented on
      the class 'Documented' when this sample program is run in a two
      slightly different ways:

      ----------------------------------------------------------------
      % java -cp classes V java.lang.annotation.Documented
      CLASS java.lang.annotation.Documented
        Annotation java.lang.annotation.Documented
        Annotation java.lang.annotation.Retention
        Annotation java.lang.annotation.Target
        
      % java -cp classes V java.lang.Deprecated java.lang.annotation.Documented
      CLASS java.lang.Deprecated
        Annotation java.lang.annotation.Documented
        Annotation java.lang.annotation.Retention
      CLASS java.lang.annotation.Documented
        Annotation java.lang.annotation.Retention
        Annotation java.lang.annotation.Target
      ----------------------------------------------------------------

      In the second run, the list of annotations is missing
      one item - the 'Documented' annotation itself.

      This bug is reproduced on the build b49.

      ======================================================================

            jjb Josh Bloch
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: