This article will shed some light onto the enhancement being made in the @Deprecated annotation in Java 9 release. Let me start with giving you some background about Deprecated interface. It isn’t new at all in the history of Java. It was introduced in Java 5. And since then, it’s considered as one of the useful feature for Java developers.  


Check out: Iterate / ofNullable operations in Java 9 Stream

@Deprecated Annotation Enhancement in Java 9...!!! Click To Tweet

For those, who are not aware of what @Deprecated annotation is. Well, any element which is annotated with @Deprecated signifies that this particular element should no longer be used for following reasons:

  • It may not be available in the future releases.
  • It may lead to errors.
  • A better alternative is available to use.

Until Java 9, If you annotate any element with @Deprecated, Compiler generates warnings.

What changed in Java 9:

With the launch of Java 9, Following two optional elements have been added into the @Deprecated interface:
1. Since
2. forRemoval

Let’s go through both of them in detail:

It’s a String type element. It returns the version in which the annotated element became deprecated. The default value of this element is empty string.


It’s a boolean type element. It indicates whether the annotated element is subject to removal in a future version. The default value of this element is false.


Both of these elements added to deprecated annotation are truly useful addition as part of Java 9. I hope above examples could help you to get better idea on how to implement it.

@Deprecated Annotation Enhancement in Java 9...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References: