RFR: JDK-8312445: Array types in annotation elements show square brackets twice

Pavel Rappo prappo at openjdk.org
Tue Jul 25 15:25:53 UTC 2023


On Tue, 25 Jul 2023 13:29:55 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> Please review a change to fix the representation of array types as values of annotation elements in javadoc-generated documentation.
> 
> The primary fix is to avoid generating duplicate `[]` brackets for array types, but there are a few secondary improvements:
> 
>  - When linking to a type, only use the type name as link label, appending the `.class` as plain text after the link
>  - Support linking to the base type of array types, again appending the square brackets and `.class` after the link
>  - Leave it to the `LinkFactory` code to decide whether to use the qualified or simple type name for a link (uses `isLinkable` instead of `isIncluded`)
> 
> There already was some test code for the use of array types in annotation elements in `TestNewLanguageFeatures.java`, but it was disabled with a comment referring to another issue that has long been resolved.

Changes requested by prappo (Reviewer).

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java line 1890:

> 1888:                         return new TextBuilder(t.toString());
> 1889:                     }
> 1890:                 }.visit(t).add(".class");

I know that naming is hard, but consider renaming this or the outer `t` so they don't name-clash. Given a parameter with the same name is also present in `defaultAction`, I'd probably renamed the outer `t`. Renaming one parameter is simpler than renaming two parameters.

test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java line 700:

> 698: 
> 699:         // XXX:  Add array test case after this if fixed:
> 700:         //5020899: Incorrect internal representation of class-valued annotation elements

Thanks for deleting this effective FIXME.

test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/pkg1/B.java line 39:

> 37:    sa = {"up", "down"},
> 38:    primitiveClassTest = boolean.class,
> 39:    arrayClassTest = String[][].class,

Update the copyright year in this file.

-------------

PR Review: https://git.openjdk.org/jdk/pull/15019#pullrequestreview-1545750651
PR Review Comment: https://git.openjdk.org/jdk/pull/15019#discussion_r1273717883
PR Review Comment: https://git.openjdk.org/jdk/pull/15019#discussion_r1273712054
PR Review Comment: https://git.openjdk.org/jdk/pull/15019#discussion_r1273708848


More information about the javadoc-dev mailing list