My own deprecated annotation
@Deprecated annotation is designed for the development environment (generally but not only). It does nothing itself. But for IDE it is the some kind of marker and when it "see" that annotation - it performs some logic (for example "strikethrough" the code). The goal of my post is to tell that it is not enough to develop and use the annotation : it must me supported by environment.
There are two things you can do:
Add the
@Deprecated
annotation to the method, and
Add a
@deprecated
tag to the javadoc of the method
You should do both!
Quoting the java documentation on this subject:
Starting with J2SE 5.0, you deprecate a class, method, or field by using the @Deprecated
annotation. Additionally, you can use the @deprecated Javadoc tag tell developers what to use instead.
Using the annotation causes the Java compiler to generate warnings when the deprecated class, method, or field is used. The compiler suppresses deprecation warnings if a deprecated compilation unit uses a deprecated class, method, or field. This enables you to build legacy APIs without generating warnings.
You are strongly recommended to use the Javadoc @deprecated
tag with appropriate comments explaining how to use the new API. This ensures developers will have a workable migration path from the old API to the new API