Java 9 @Deprecated Enhancements


This article introduces new added methods of Java 9 @Deprecated annotation: forRemoval() and since().

An example with new @Deprecated annotation:
@Deprecated(since ="1.5", forRemoval = true)

1. forRemoval()

forRemoval() returns a boolean:
true means that “this API element is earmarked for removal in a future release”. Who uses the API should notice that, if they don’t migrate away from the API, their code could be break when new release is issued.
false indicates that the API element is deprecated, but without any specific intent to remove that API in the future. It is just a recommendation to migrate away from this API.

The default value of this element is false.

2. since()

since() returns a String.
“This string should contain the release or version number at which this API became deprecated.” Although it has free-form syntax, the string should follow the same scheme as the @since Javadoc tag for the project containing the deprecated API.

The default value of this element is the empty string.

You can find more features at our site: Java 9 Tutorial.

By grokonez | March 22, 2017.

Last updated on September 11, 2018.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *