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

Rendering of supertype_target for annotated extends clause

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • tools
    • b138
    • generic
    • generic
    • Verified

      This report came from Werner Dietl:

      I have a question about the type_index field in TypeAnnotationPosition.java:

      http://hg.openjdk.java.net/jdk8/jdk8/langtools/file/1ff9d5118aae/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java#l147
      http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/3665ebc22a42/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java#l147

      For class extends clauses this field will be -1 and for interface
      implements clauses the index will correspond to the index of the
      implemented interface.

      The -1 is written as two bytes, 0xFFFF, at:

      http://hg.openjdk.java.net/jdk8/jdk8/langtools/file/1ff9d5118aae/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java#l948
      http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/3665ebc22a42/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java#l906

      However, when the 0xFFFF bytes are read back in, at:

      http://hg.openjdk.java.net/jdk8/jdk8/langtools/file/1ff9d5118aae/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java#l1566
      http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/3665ebc22a42/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java#l1683

      the type index is set to 65535.

      On the other hand, at:

      http://hg.openjdk.java.net/jdk8/jdk8/langtools/file/1ff9d5118aae/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java#l134
      http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/3665ebc22a42/src/jdk.jdeps/share/classes/com/sun/tools/classfile/TypeAnnotation.java#l134

      the value 0xFFFF is special-cased and replaced by -1.

      As javap is using the correct version from
      classfile/TypeAnnotation.java I don't see a simple way to illustrate
      the issue.
      If you write an annotation processor that sees a class extends
      annotation, you would observe 65535 instead of -1.

      I think the mismatch between jvm/ClassReader and
      classfile/TypeAnnotation must be fixed to ensure a consistent
      interpretation.

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: