JDK-7006578 : Project Coin: Retrofit JDK libraries with @SafeVarargs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-12-14
  • Updated: 2017-05-16
  • Resolved: 2011-05-17
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 b130Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
With the addition of language support a SafeVarargs annotation type (7006129, 6993978), the JDK libraries should be updated to use this feature.

Comments
PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk7/tl/jdk/rev/dbfc1e419cb2
25-01-2011

SUGGESTED FIX # HG changeset patch # User darcy # Date 1295928248 28800 # Node ID dbfc1e419cb2340aea87ebc6bb6679bb19b45d73 # Parent 4cc4472913266c63cf7234cd75a1ee25a4367b12 7006578: Project Coin: Retrofit JDK libraries with @SafeVarargs Reviewed-by: mduigou, alexp --- a/src/share/classes/java/util/Arrays.java Mon Jan 24 11:47:06 2011 -0800 +++ b/src/share/classes/java/util/Arrays.java Mon Jan 24 20:04:08 2011 -0800 @@ -2823,6 +2823,7 @@ public class Arrays { * @param a the array by which the list will be backed * @return a list view of the specified array */ + @SafeVarargs public static <T> List<T> asList(T... a) { return new ArrayList<>(a); } --- a/src/share/classes/java/util/Collections.java Mon Jan 24 11:47:06 2011 -0800 +++ b/src/share/classes/java/util/Collections.java Mon Jan 24 20:04:08 2011 -0800 @@ -3827,6 +3827,7 @@ public class Collections { * @see Collection#addAll(Collection) * @since 1.5 */ + @SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements) { boolean result = false; for (T element : elements) --- a/src/share/classes/java/util/EnumSet.java Mon Jan 24 11:47:06 2011 -0800 +++ b/src/share/classes/java/util/EnumSet.java Mon Jan 24 20:04:08 2011 -0800 @@ -317,6 +317,7 @@ public abstract class EnumSet<E extends * or if <tt>rest</tt> is null * @return an enum set initially containing the specified elements */ + @SafeVarargs public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) { EnumSet<E> result = noneOf(first.getDeclaringClass()); result.add(first); --- a/src/share/classes/javax/swing/SwingWorker.java Mon Jan 24 11:47:06 2011 -0800 +++ b/src/share/classes/javax/swing/SwingWorker.java Mon Jan 24 20:04:08 2011 -0800 @@ -404,6 +404,7 @@ public abstract class SwingWorker<T, V> * @see #process * */ + @SafeVarargs protected final void publish(V... chunks) { synchronized (this) { if (doProcess == null) { --- a/src/share/classes/sun/swing/AccumulativeRunnable.java Mon Jan 24 11:47:06 2011 -0800 +++ b/src/share/classes/sun/swing/AccumulativeRunnable.java Mon Jan 24 20:04:08 2011 -0800 @@ -120,6 +120,7 @@ public abstract class AccumulativeRunnab * {@code Runnable} for execution. * @param args the arguments to accumulate */ + @SafeVarargs public final synchronized void add(T... args) { boolean isSubmitted = true; if (arguments == null) {
25-01-2011

EVALUATION A fine idea.
14-12-2010