Annotation Interface Deprecated
@Deprecated is one that programmersare discouraged from using. An element may be deprecated for any of severalreasons, for example, its usage is likely to lead to errors; it maybe changed incompatibly or removed in a future version; it has beensuperseded by a newer, usually preferable alternative; or it is obsolete.Compilers issue warnings when a deprecated program element is used oroverridden in non-deprecated code. Use of the@Deprecatedannotation on a local variable declaration or on a parameter declarationor a package declaration has no effect on the warnings issued by a compiler.
When a module is deprecated, the use of that module inrequires, but not inexports oropens clauses causesa warning to be issued. A module being deprecated doesnot causewarnings to be issued for uses of types within the module.
This annotation type has a string-valued elementsince. The valueof this element indicates the version in which the annotated program elementwas first deprecated.
This annotation type has a boolean-valued elementforRemoval.A value oftrue indicates intent to remove the annotated programelement in a future version. A value offalse indicates that use ofthe annotated program element is discouraged, but at the time the programelement was annotated, there was no specific intent to remove it.
- API Note:
- It is strongly recommended that the reason for deprecating a program elementbe explained in the documentation, using the
@deprecatedjavadoc tag. The documentation should also suggest and link to arecommended replacement API, if applicable. A replacement API oftenhas subtly different semantics, so such issues should be discussed aswell.It is recommended that a
sincevalue be provided with all newlyannotated program elements. Note thatsincecannot be mandatory,as there are many existing annotations that lack this element value.There is no defined order among annotation elements. As a matter ofstyle, the
sinceelement should be placed first.The
@Deprecatedannotation should always be present ifthe@deprecatedjavadoc tag is present, and vice-versa. - SeeJava Language Specification:
- 9.6.4.6 @Deprecated
- Since:
- 1.5
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanIndicates whether the annotated element is subject to removal in afuture version.Returns the version in which the annotated element became deprecated.
Element Details
since
String sinceReturns the version in which the annotated element became deprecated.The version string is in the same format and namespace as the value ofthe@sincejavadoc tag. The default value is the emptystring.- Returns:
- the version string
- Since:
- 9
- Default:
""
forRemoval
boolean forRemovalIndicates whether the annotated element is subject to removal in afuture version. The default value isfalse.- Returns:
- whether the element is subject to removal
- Since:
- 9
- Default:
false