Code Snippets: How to use the deprecated and link javadoc tags

Over the lifespan of a software’s code source you will inevitably have to rename functions and properties of classes and maybe even remove them all together. This is not a major issue on simple projects but when your project is used by multiple applications then you may find that you need to keep these deprecated functions until other projects update their code to the new values. The Javadoc deprecated tag is how you mark a function or property as no longer in use and link to the new property or function to use.

The Deprecated Tag

The deprecated tag marks the current property or function as no longer in use. To use the tag simply add it into your Javadoc comments on its own line proceeded by the @ symbol.

/**
 * VIEW - ACTION TYPE
 * @deprecated 
 */
public static final String VIEW = "View";

The Link Tag

When you mark a property or function as deprecated it is always a good idea to link to the new property or function by use of the link tag. You can link to a property/value in the current class or to a property/value in another class.

Link in the current class

/**
 * VIEW - ACTION TYPE
 * @deprecated replaced by {@link #ACTION_VIEW}
 */
public static final String VIEW = "view";

Link in another class

/**
 * filters valid records
 * @deprecated replaced by {@link com.test.TestClass#filter()}
 */

Resources

// Code Snippets // Java //

Comments & Questions

Add Your Comment