Domanda

I compile javac 1.7.0_45 using the -Xlint option, the following code causes a deprecation warning.

@Deprecated
public class Bar {}

@SuppressWarnings("deprecation")
public class Foo {    
  @XmlElement(type = Bar.class)
  Object something;
}

>> Warning: Bar in mavenproject1 has been deprecated

I would have expected the @SuppressWarnings to prevent the warning message to be raised.

How to avoid this warning ?

È stato utile?

Soluzione

I have a feeling this is a bug / spec ambiguity that hasn't been addressed. If you search the bug database there are plenty of these, such as: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7117383

Altri suggerimenti

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Deprecated.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top