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

TYPE_USE annotations not printed in correct position in toString output

XMLWordPrintable

    • b10
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "17" 2021-09-14
      OpenJDK Runtime Environment (build 17+35-2724)
      OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      TypeMirror's documentation says that a the result of a toString() should try to be valid to use in source code.



          /**
           * Returns an informative string representation of this type. If
           * possible, the string should be of a form suitable for
           * representing this type in source code. Any names embedded in
           * the result are qualified if possible.
           *
           * @return a string representation of this type
           */




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Make an annotation whose target is TYPE_USE

      @Target({ElementType.TYPE_USE})
      @interface ExampleAnn {}

      2. Write some code which uses that annotation on a field type

      class Example {
          @ExampleAnn String abc;
      }

      3. Obtain a TypeMirror of the VariableElement via an annotation processor.

      4. Using .toString() on that TypeMirror


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      java.lang.@ExampleAnn String
      ACTUAL -
      @ExampleAnn java.lang.String

      ---------- BEGIN SOURCE ----------
      // Code for this requires setting up the scaffolding for an annotation processor

      ---------- END SOURCE ----------

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: