Suppress deprecated import warning in Java

Viewed 84457

In Java, if you import a deprecated class:

import SomeDeprecatedClass;

You get this warning: The type SomeDeprecatedClass is deprecated

Is there a way to suppress this warning?

7 Answers

I solved this by changing the import to:

import package.*

then annotating the method that used the deprecated classes with@SuppressWarnings("deprecation")

If @SuppressWarnings("deprecation") is not working for you like for me. You can find exact squid number in sonar lint plugin. And then you can simply suppress warning: @SuppressWarnings("squid:CallToDeprecatedMethod")

enter image description here

Related