No compilation warning with @Deprecated annotation?

According to the Java Oracle tutorial , if using an obsolete method marked with @Deprecated annotations, the compiler should give a compilation warning. But with the following code example, I don't get a warning in the console.

Used Java Version: 1.8.0_112

Please let me know what is missing here. Thank.

public class PreDefinedAnnotationTypesTest {

/**
 * This method is deprecated.
 * @deprecated
 */
@Deprecated
public void m1(){

}

public static void main(String[] args) {
    PreDefinedAnnotationTypesTest obj = new PreDefinedAnnotationTypesTest();
    obj.m1();
}

}

+4
source share
2 answers

From the documents

The compiler suppresses obsolescence warnings if an obsolete element is used in an entity that is itself deprecated or is used within the same outermost class, or is used in an entity that annotates to suppress the warning.

, , - .

wontShowWarning , show() funtion , .

API , , , .

enter image description here

+4

Java- :

javac -Xlint className.java

: https://i.stack.imgur.com/fwVjQ.png

0

Source: https://habr.com/ru/post/1661015/


All Articles