Tuesday 26 January 2021

Java9: Deprecation Warnings on Import Statements

While working with Java applications, if you import any deprecated APIs/ use deprecated member , java compiler will throw warnings at the time of compilation. Most of these warnings are uninformative and should not be required.

 

From Java9 onwards, compiler suppress deprecated warnings if one of the following case occur.

 

a.   The use is within an entity that is itself annotated with the annotation @Deprecated

b.   The use is within an entity that is annotated to suppress the warning with the annotation @SuppressWarnings("deprecation")

c.    The use and declaration are both within the same outermost class.

d.   The use is within an import statement.

 

Reference

https://openjdk.java.net/jeps/211

Previous                                                    Next                                                    Home

No comments:

Post a Comment