JDK-6512103 : Annotation-qualified optional disallowance of raw generic types
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-01-11
  • Updated: 2011-10-31
  • Resolved: 2011-10-31
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
Mixing raw and parameterized generic types is error-prone. It would be useful to have a compiler option to reject use of raw types but to be able to annotate a class or method to exempt the annotated code from this behavior.

  Suggested annotation: @PermitRawTypes



JUSTIFICATION :
  To avoid erroneous use of raw types.


CUSTOMER SUBMITTED WORKAROUND :
Eclipse now provides the desired compiler option, but without the permissive annotation.

Comments
EVALUATION Given the very strong statement in JLS 4.8 - "It is possible that future versions of the Java programming language will disallow the use of raw types" - it would not be sensible to add @PermitRawTypes and thus embed raw types into the JLS more deeply than they already are. Once present in the JLS, we can never drop that annotation. A better approach is for compilers to agree on a string parameter to @SuppressWarnings. javac supports -Xlint:rawtypes on the command line and therefore @SuppressWarnings("rawtypes") too. ecj supports -warn:raw on the command line, that alters the behavior of the standard @SuppressWarnings("unchecked"), but does not support @SuppressWarnings("raw") per se [1,2]. [1] http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm [2] http://www.breakitdownblog.com/supported-values-for-suppresswarnings/
12-01-2007