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

Mixup between binary names and descriptors in Runtime*Annotations attributes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 7
    • specification
    • vm
    • rc
    • generic
    • generic
    • Verified

      JVMS3 4.7.16 and 4.7.16.1 describe how type names are stored in the ClassFile attributes for annotations. (The JVMS3 text is taken from http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf)

      [4.7.16] annotations.element_value_pairs[].element_name_index points to a CONSTANT_Utf8_info representing "the name of the annotation type element".

      [4.7.16.1] annotations.element_value_pairs[].element_value.enum_const_value.type_name_index points to a CONSTANT_Utf8_info representing "the internal form of the binary name (§4.2.1) of the type of the enum constant represented by this element_value structure."

      In both cases, javac emits a descriptor for the CONSTANT_Utf8_info. This is overkill, since only class/interface names can possibly appear as the name of an annotation type or an enum constant, and class/interface names can be fully encoded with just a binary name. But what javac writes does appear to agree with what java.lang.reflect.Class.getAnnotations() reads.

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: