JDK-6707041 : Add a message field to @Deprecated annotation
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0,7
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux,windows_7
  • CPU: x86
  • Submitted: 2008-05-26
  • Updated: 2012-07-18
  • Resolved: 2009-07-27
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Right now the @Deprecated annotation is just a marker interface.  We also have the @deprecated javadoc tag.  So there's overlap between these two options, but you have to use both of them when marking something as deprecated.  You really only need one.  So add the ability to specify the javadoc message in the @Deprecated annotation.  Like:
 
@Deprecated( message = "Don't use this @see( java.lang.Number )" )


JUSTIFICATION :
Adding the message to the @Deprecated tags make it easier for developers to use this annotation and have the compiler and javadoc respond to it.  Right now it's an either or situation.  Either specify the javadoc, and the compiler does nothing, or specify the @Decprecated annoation the compiler will complain and the javadoc just says it's deprecated, but gives no alternatives.  Allow us to use one thing (@Deprecated) and get the features from both.  Compiler warnings, and nice javadoc.  And, the compiler can spit out the message so the developer doesn't have to goto his/her browser to find the alternative.  Much better experience.  You can even force people to give a message with the annotation.

That was the whole point of annotation's right?  So many tools could all use the same meta data.

Comments
EVALUATION The reason for the deprecation better lives in the javadoc where you have the full expressive power of javadoc, including links to the recommended alternative. In short, you are recommended to mark the API with @Deprecated, but to provide the corresponding documentation with /** @deprecated */
27-07-2009