@Retention(RUNTIME)
@Target({CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE})
public abstract @interface Deprecated
@Deprecated
is one that programmers are discouraged from using. An element may be deprecated for any of several reasons, for example, its usage is likely to lead to errors; it may be changed incompatibly or removed in a future version; it has been superseded by a newer, usually preferable alternative; or it is obsolete. Compilers issue warnings when a deprecated program element is used or overridden in non-deprecated code. Use of the @Deprecated
annotation on a local variable declaration or on a parameter declaration or a package declaration has no effect on the warnings issued by a compiler.
When a module is deprecated, the use of that module in requires
, but not in exports
or opens
clauses causes a warning to be issued. A module being deprecated does not
cause warnings to be issued for uses of types within the module.
This annotation type has a string-valued element since
. The value of this element indicates the version in which the annotated program element was first deprecated.
This annotation type has a boolean-valued element forRemoval
. A value of true
indicates intent to remove the annotated program element in a future version. A value of false
indicates that use of the annotated program element is discouraged, but at the time the program element was annotated, there was no specific intent to remove it.
- API Note:
- It is strongly recommended that the reason for deprecating a program element be explained in the documentation, using the
@deprecatedjavadoc tag. The documentation should also suggest and link to a recommended replacement API, if applicable. A replacement API often has subtly different semantics, so such issues should be discussed as well.It is recommended that a
sincevalue be provided with all newly annotated 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 of style, the
sinceelement should be placed first.The
@Deprecatedannotation should always be present if the@deprecatedjavadoc tag is present, and vice-versa. - See Java Language Specification:
- Moved out of a link with destination https://docs.oracle.com/javase/specs/jls/se20/html/jls-9.html#jls-9.6.4.6.Moved to a link with destination https://docs.oracle.com/javase/specs/jls/se21/html/jls-9.html#jls-9.6.4.6. Moved out of a link with destination https://docs.oracle.com/javase/specs/jls/se20/html/jls-9.html#jls-9.6.4.6.Moved to a link with destination https://docs.oracle.com/javase/specs/jls/se21/html/jls-9.html#jls-9.6.4.6.9.6.4.6 @Deprecated
- Since:
- 1.5
Elements
- ✓public abstract boolean forRemoval() default false
- ✓public abstract java.lang.String since() default ""
Summary
| Elements | Comments | Descriptions | Total | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed | ||
| Deprecated | 1 | 1 | ||||||||
| Total | 1 | 1 | ||||||||