I have an interface with a deprecated method:
public interface A
{
@Deprecated
public String getUUID();
}
And another interface with the same but non-deprecated method:
public interface B
{
public String getUUID();
}
A class that implements both interfaces:
public class MyBean implements A, B
{
@Override
public String getUUID()
{
return UUID.randomUUID().toString();
}
}
There is a warning during the compilation of MyBean
:
javac -Xlint:deprecation MyBean.java A.java B.java
MyBean.java:8: warning: [deprecation] getUUID() in A has been deprecated
public String getUUID()
^
1 warning
I cannot really understand why is this warning necessary when I implement B
which defines the non-deprecated method...
You already answered your question.
You get the warning because you do implement A
, which has the @Deprecated
annotation. See here:
@Deprecated annotation indicates that the marked element is deprecated and should no longer be used. The compiler generates a warning whenever a program uses a method, class, or field with the @Deprecated annotation.
I don't see anything wrong with that warning. It should be there as you are really implementing a Deprecated method that's found in one of the interfaces you're implementing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With