JDK-8312445 : Array types in annotation elements show square brackets twice
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2023-07-20
  • Updated: 2023-07-31
  • Resolved: 2023-07-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b08Fixed
Related Reports
Relates :  
Description
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
------------------------------------------------------------------
Comments
Changeset: 02a04731 Author: Hannes Wallnöfer <hannesw@openjdk.org> Date: 2023-07-26 13:04:39 +0000 URL: https://git.openjdk.org/jdk/commit/02a04731b1b2e68bf1a79f50d036bedd032128f0
26-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15019 Date: 2023-07-25 13:29:55 +0000
25-07-2023

The problem is in the `annotationValueToContent` method in `HtmlDocletWriter`, where `utils.getDimension(t)` is added to the type name which already includes the correct number of square brackets.
20-07-2023