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

Array types in annotation elements show square brackets twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 22
    • None
    • tools
    • None
    • b08
    • generic
    • generic

      When an array type is used as a value in an annotation element, each pair of square brackets is printed twice. This means a one-dimensional array type is rendered as two-dimensional, a two-dimensional array type as four-dimensional and so on.

      Example annotation interface:
      --------------------------------------------------------------------
      import java.lang.annotation.*;
       
      @Documented
      @Retention(RetentionPolicy.RUNTIME)
      public @interface MyAnnotation {
          Class<?> classy();
          Class<?>[] classies();
      }
      ---------------------------------------------------------------

      Example annotation host:
      ---------------------------------------------------------------
      @MyAnnotation(classy=AnnotationHost[].class,
                    classies={Object[].class, int[].class})
      public class AnnotationHost {}
      ---------------------------------------------------------------

      JavaDoc output:
      ------------------------------------------------------------------
      @MyAnnotation(classy=AnnotationHost[][].class,
                    classies={java.lang.Object[][].class,int[][].class})
      public class AnnotationHost
      extends Object
      ------------------------------------------------------------------

            hannesw Hannes Wallnoefer
            hannesw Hannes Wallnoefer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: