Parent issue: #19807
Coverage table
Chapter link
Content
Image
Text
Custom Tags and Annotations
If annotations are new to you, when you need to markup your source code, it might not be immediately clear whether to use an annotation or a Javadoc custom tag. Here is a quick comparison of the two.
In general, if the markup is intended to affect or produce documentation, it should probably be a javadoc tag; otherwise, it should be an annotation.
- Tag - Intended as a way of adding structure and content to the documentation. Allows multi-line text to be provided. (Use the -tag or -taglet Javadoc option to create custom tags.) Tags should never affect program semantics.
- Annotation - Does not directly affect program semantics, but does affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time. Allows a single line of text to be provided.
If you need to affect both program semantics and documentation, you probably need both an annotation and a tag. For example, our guidelines now recommend using the @Deprecated annotation for alerting the compiler warning and the @deprecated tag for the comment text.
Guidelines
our guidelines now recommend using the @Deprecated annotation for alerting the compiler warning and the @deprecated tag for the comment text
This chapter is covered by MissingDeprecated. Proposal:
| Documentation Comments Rule |
Checkstyle Checks Used |
Sample files |
Custom Tags and Annotations |
✅MissingDeprecated |
|

Parent issue: #19807
Coverage table
Chapter link
Content
Image
Text
Custom Tags and Annotations
If annotations are new to you, when you need to markup your source code, it might not be immediately clear whether to use an annotation or a Javadoc custom tag. Here is a quick comparison of the two.
In general, if the markup is intended to affect or produce documentation, it should probably be a javadoc tag; otherwise, it should be an annotation.
If you need to affect both program semantics and documentation, you probably need both an annotation and a tag. For example, our guidelines now recommend using the
@Deprecatedannotation for alerting the compiler warning and the@deprecatedtag for the comment text.Guidelines
This chapter is covered by MissingDeprecated. Proposal:
Custom Tags and Annotations