JDK-6908218 : java.lang.Deprecated should have explicit @Target meta-annotation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-12-08
  • Updated: 2017-05-16
  • Resolved: 2010-01-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b81Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The annotation type java.lang.Deprecated does not have an explicit @Target meta-annotation; therefore, in can be applied in all possible locations even though it is not meaningful in some of those locations.  As part of JSR 308, new locations were added and thereby Deprecated can now appear in still more locations without defined meaning.
See also discussion in thread
http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-January/thread.html#3489
See
http://hg.openjdk.java.net/jdk7/tl/jdk/rev/fa0cb25202d8

Comments
SUGGESTED FIX # HG changeset patch # User darcy # Date 1263528319 28800 # Node ID fa0cb25202d8e8170d00e69a5fd5fe98576bf39b # Parent ba74184a952c847ad696ed86a22485853c25f3ce 6908218: java.lang.Deprecated should have explicit @Target meta-annotation. Reviewed-by: mernst --- a/src/share/classes/java/lang/Deprecated.java Tue Jan 12 15:19:24 2010 -0800 +++ b/src/share/classes/java/lang/Deprecated.java Thu Jan 14 20:05:19 2010 -0800 @@ -26,6 +26,7 @@ package java.lang; package java.lang; import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; /** * A program element annotated @Deprecated is one that programmers @@ -38,5 +39,6 @@ import java.lang.annotation.*; */ @Documented @Retention(RetentionPolicy.RUNTIME) +@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) public @interface Deprecated { } --- a/src/share/classes/java/lang/SuppressWarnings.java Tue Jan 12 15:19:24 2010 -0800 +++ b/src/share/classes/java/lang/SuppressWarnings.java Thu Jan 14 20:05:19 2010 -0800 @@ -26,7 +26,6 @@ package java.lang; package java.lang; import java.lang.annotation.*; -import java.lang.annotation.ElementType; import static java.lang.annotation.ElementType.*; /** @@ -45,7 +44,7 @@ import static java.lang.annotation.Eleme * @since 1.5 * @author Josh Bloch */ -@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE}) +@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, TYPE_PARAMETER}) @Retention(RetentionPolicy.SOURCE) public @interface SuppressWarnings { /**
15-01-2010

EVALUATION Deprecated should be restricted to only be targetable to the set of locations that a missing @Target meant in JDK 5/6.
08-12-2009