184 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES
184 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES That is the whole annotation declaration; it is like a class definition. It is for the predefined annotation Deprecated, to be described shortly. JDK 5.0 Annotations JDK 5.0 introduces three annotations: @Deprecated, @SuppressWarnings, and @Override. Let s take a quick look at what was available to us before Java SE 6.0. The @Deprecated Annotation One of the JDK 5.0 annotations is @Deprecated. Notice the difference in case. It is different from the javadoc @deprecated tag, as it doesn t go in javadoc comments. Instead, you place @Deprecated above the method or class you want to flag as out of date. The positioning of both tags is shown in Listing 10-1. Listing 10-1. @Deprecated Annotation Usage public class Dep { /** * @deprecated Don’t use this method any more. */ @Deprecated public static void myDeprecatedMethod() { System.out.println(”Why did you do that?”); } } class DeprecatedUsage { public void useDeprecatedMethod() { Dep.myDeprecatedMethod(); } } There is a second class in Listing 10-1 that uses the deprecated method: DeprecatedUsage. When you compile the source code with the javac compiler, you get a warning: > javac Dep.java Note: Dep.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services