Enhanced@Deprecated Annotation


@Deprecated Annotation was launched in java 5 Version. Program components annotated with @deprecated means it must not be used for any of the reason which given below:

  • Its use may show the error
  • It might be incompatible in the upcoming versions
  • It might be detached in the upcoming Versions
  • Its good and well-organized alternative has replaced it.

Assembler produces a warning whenever a deprecated component is used. With the Java 9 launch, two new improvements are made to @deprecated Annotation

  • forRemoval − Shows whether the annotated component is subject to detachment in upcoming versions. The default value is false.
  • since − Back with the version in which the annotated components became deprecated. The default value is the empty(vacant) string.

Deprecated with since

Boolean class javadoc on Java 9 to demonstrate the use of since attribute on @Deprecated annotation in the below given example:

Boolean Class

Deprecated with forRemoval

System Class Javadoc on Java 9 to demonstrate the use of forRemoval attribute on @Deprecated Annotation, in the below-given example:

System Class