To find outdated methods and classes, you do what the quoted text says. You compile with the "-deprecation" switch, and the insult methods / classes will appear as warning compilation messages. (If you are using the IDE, deprecation alerts will be activated / deactivated in some other way.)
If you really ask how the compiler knows that the method or class is deprecated, the answer is that the class or method is deprecated by putting the "@deprecated" tag in the corresponding javadoc comment. The java compiler notes this and sets the attribute in the bytecode file when compiling the class. Then, when you try to use the class / method in your code, the java compiler reads the bytecodes, marks the attribute, and displays a warning message.
Obsolescence is intended as a strong hint to the developer that this method or class should no longer be used. An obsolete class or method usually has some flaws in it (primary or secondary) that cannot be fixed without breaking existing code. Instead, an incompatible replacement has been implemented that requires some changes to the source code.
Theoretically obsolete classes and methods may be removed in future releases. Although Sun rarely (if ever) does this, third-party library developers are more willing to remove obsolete methods when cleaning up their APIs.
source share