-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b123
-
generic
-
generic
-
Verified
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.
* 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.
- relates to
-
JDK-7006129 Project Coin: Annotation type to reduce varargs warnings
-
- Closed
-
-
JDK-7006578 Project Coin: Retrofit JDK libraries with @SafeVarargs
-
- Closed
-
-
JDK-6945418 Project Coin: Simplified Varargs Method Invocation
-
- Closed
-
-
JDK-7196160 Project Coin: Allow @SafeVarargs on private methods
-
- Closed
-
-
JDK-8279291 Remove restrictions from @SafeVarargs
-
- Closed
-