JDK-6993978 : Project Coin: Compiler support of annotation to reduce varargs warnings
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-10-21
  • Updated: 2021-12-27
  • Resolved: 2011-03-08
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 b123Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The initial prototype implementation of simplified varargs method invocation (6945418) used the SuppressedWarnings annotation to indicate a method should be trusted.  The final annotation to indicate trustedness needs to be @Documented so it is part of the method's contract.  The "trust me" annotation is only meaningfully applicable to

* static methods
* constructors
* (possibly) final methods

Since method-level annotations are *not* inherited, the annotation cannot be sensibly used on general instance methods.

To "trust but verify," when the annnotation is applied to a method, the compiler will perform some checks to validate the var-args array argument is being used safely.  At a first cut of safety preserving checks:

* The var-args parameter is not aliased to any other reference, especially not to an Object or Object[]
* The array is only read from and not written to.  Calls to hashCode, toString, etc. would be fine as well.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/langtools/rev/7b99f98b3035
25-12-2010

PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk7/tl/langtools/rev/7b99f98b3035
14-12-2010

EVALUATION This bug will be used for tracking the compiler changes needed to support the SafeVarargs annotation.
10-12-2010

EVALUATION Yes.
21-10-2010