JDK-6428760 : Need Annotation @Denigrated
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2006-05-22
  • Updated: 2016-04-20
  • Resolved: 2006-10-25
Related Reports
Relates :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
There needs to be an annotation (possibly one that generates warnings) so that Sun can represent classes that have been replaced by better options, but haven't deprecated.

EG: StringTokenizer has been denigrated in favour of RegEx.

JUSTIFICATION :
I believe that bugs filed against some features almost never get fixed, because they've been replaced by other more functional pieces. This would allow developers to know that there's a better way to do something.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A simple warning at compile time that this class has been replaced by something else:

"Denigration warning: Use of StringTokenizer should be replaced by a use of Pattern.matches()"

Comments
This is now covered by JEP 277 (JDK-8065614) Enhanced Deprecation.
20-04-2016

EVALUATION ----------------------- Nobody seems to disagree that this is not appropriate for a language feature. However, this RFE asks for a compiler warning on a new annotation. That would be a langauge feature or a compiler RFE. Rather than deciding that this RFE is asking for something it is not, I think it would be better to file a new RFE asking for something different.
25-10-2006

EVALUATION More doable would be a new Javadoc tag along these lines.
24-10-2006

EVALUATION @Deprecated is simple - a program element is either deprecated or it's not. The heart of @Denigrated is that it suggests an alternative (so the compiler can display it). So really, if something is @Denigrated, the compiler must look up the alternative, and check if it's @Denigrated or @Deprecated (no point suggesting it if it is), and so on. @Denigrated is a nice little software engineering idea, but I don't think it's important enough to add to the JLS at this point.
24-10-2006