What are the improvements for @Deprecated annotation in Java 9?

Any element that can be annotated with @Deprecated signifies that this particular element no longer be used for below reasons

  • Using it is risky and may cause errors.
  • May be incompatible in future versions.
  • May be removed in future versions.
  • A better and more efficient solution has replaced it.

Java 9 has added two new elements: since and forRemoval attributes.

1) since: The element specifies the deprecated version of the annotated API element.

2) forRemoval: The element representing the annotated API element can be removed in a future version, and the API can be migrated.

The following webpage is the documentation for a Boolean class in Java 9. The @Deprecated annotation uses the "since" attribute in the document: Boolean Class.

The following webpage is a description of the System class in Java 9. The @Deprecated annotation in the document uses the "forRemoval" attribute: System Class.