Here's an example of using @SuppressWarnings to suppress a deprecation warning:
class Test {
@Deprecated
interface Foo { }
@SuppressWarnings("deprecation")
interface Bar extends Foo { }
}
Now consider the case where Foo and Bar are in separate source files:
Foo.java:
@Deprecated
interface Foo { }
Bar.java
@SuppressWarnings("deprecation")
interface Bar extends Foo { }
In that case it doesn't seem to be possible to suppress the warning:
$ javac -Xlint:all Foo.java Bar.java
Bar.java:2: warning: [deprecation] Foo in unnamed package has been deprecated
interface Bar extends Foo { }
^
1 warning
class Test {
@Deprecated
interface Foo { }
@SuppressWarnings("deprecation")
interface Bar extends Foo { }
}
Now consider the case where Foo and Bar are in separate source files:
Foo.java:
@Deprecated
interface Foo { }
Bar.java
@SuppressWarnings("deprecation")
interface Bar extends Foo { }
In that case it doesn't seem to be possible to suppress the warning:
$ javac -Xlint:all Foo.java Bar.java
Bar.java:2: warning: [deprecation] Foo in unnamed package has been deprecated
interface Bar extends Foo { }
^
1 warning
- duplicates
-
JDK-6480588 No way to suppress deprecation warnings when implementing deprecated interface
- Resolved
- relates to
-
JDK-8022474 @SuppressWarnings("deprecation") Doesn't Work As Expected
- Closed