Skip to content

Documentation Comments Style Guide - @deprecated #19921

@gianmarcoschifone

Description

@gianmarcoschifone

Parent issue: #19807

Coverage table

Chapter link

Content

Image

Image

Text

@deprecated (reference page)

The @deprecated description in the first sentence should at least tell the user when the API was deprecated and what to use as a replacement. Only the first sentence will appear in the summary section and index. Subsequent sentences can also explain why it has been deprecated. When generating the description for a deprecated API, the Javadoc tool moves the @deprecated text ahead of the description, placing it in italics and preceding it with a bold warning: "Deprecated". An @see tag (for Javadoc 1.1) or {@link} tag (for Javadoc 1.2 or later) should be included that points to the replacement method:

For Javadoc 1.2 and later, the standard format is to use @deprecated tag and the in-line {@link} tag. This creates the link in-line, where you want it. For example:

/**
* @deprecated  As of JDK 1.1, replaced by
*              {@link #setBounds(int,int,int,int)}
*/

For Javadoc 1.1, the standard format is to create a pair of @deprecated and @see tags. For example:

/**
* @deprecated  As of JDK 1.1, replaced by 
*               
 setBounds
* @see #setBounds(int,int,int,int)
*/

If the member has no replacement, the argument to @deprecated should be "No replacement".

Do not add @deprecated tags without first checking with the appropriate engineer. Substantive modifications should likewise be checked first.

Guidelines

NonEmptyAtclauseDescription checks that a block tag (e.g., @deprecated) is followed by a description. Proposal:

Documentation Comments Rule Checkstyle Checks Used Sample files
@deprecated ✅NonEmptyAtclauseDescription
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions