[PATCH] Documented annotations for primitive types

Aaloan Miftah al at poly-gamma.org
Fri Mar 24 18:59:43 UTC 2023


Hello,

Currently when a primitive type is annotated with a `@Documented`
annotation, the fqn of the annotation(s)
is always included in the resulting javadoc, and links aren't properly
inserted. For example,

``
public abstract void
foo(@org.checkerframework.checker.signedness.qual.Unsigned int bar);
``

The `bar` parameter, in the resulting javadoc, is documented with the fqn
`org.checkerframework.checker.signedness.qual.Unsigned` annotation, instead
of just `Unsigned` with a link
to the annotation.

This patch fixes
jdk.javadoc.internal.doclets.formats.html.HtmlLinkFactory::getLink() by
introducing special
handling for primitive types that takes their use annotation into account,
and prints the simple type name.
Note that the type name is currently being derived using
PrimitiveType::getKind() instead of
utils::getTypeName(), this is because the toString() for the default case
in getTypeName() will always include
the annotations, which we want to avoid. I didn't modify
utils::getTypeName() since I wasn't sure if a primitive
specific visit method would mess with any expected behavior.

Cheers,
Al
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/javadoc-dev/attachments/20230324/9da80fde/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/javadoc-dev/attachments/20230324/9da80fde/patch.diff>


More information about the javadoc-dev mailing list