From 43e51855df0ba1407e3c9011cdfe2c3375c4b9f6 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 24 Jan 2011 20:04:08 -0800 Subject: [PATCH] 7006578: Project Coin: Retrofit JDK libraries with @SafeVarargs Reviewed-by: mduigou, alexp --- jdk/src/share/classes/java/util/Arrays.java | 1 + jdk/src/share/classes/java/util/Collections.java | 1 + jdk/src/share/classes/java/util/EnumSet.java | 1 + jdk/src/share/classes/javax/swing/SwingWorker.java | 1 + jdk/src/share/classes/sun/swing/AccumulativeRunnable.java | 1 + 5 files changed, 5 insertions(+) diff --git a/jdk/src/share/classes/java/util/Arrays.java b/jdk/src/share/classes/java/util/Arrays.java index 6a03fbfb41f..a743e62ca86 100644 --- a/jdk/src/share/classes/java/util/Arrays.java +++ b/jdk/src/share/classes/java/util/Arrays.java @@ -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 List asList(T... a) { return new ArrayList<>(a); } diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index bfd5a8711d6..1ea0ecb04c0 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -3827,6 +3827,7 @@ public class Collections { * @see Collection#addAll(Collection) * @since 1.5 */ + @SafeVarargs public static boolean addAll(Collection c, T... elements) { boolean result = false; for (T element : elements) diff --git a/jdk/src/share/classes/java/util/EnumSet.java b/jdk/src/share/classes/java/util/EnumSet.java index cbf355fd72a..4e5dd473134 100644 --- a/jdk/src/share/classes/java/util/EnumSet.java +++ b/jdk/src/share/classes/java/util/EnumSet.java @@ -317,6 +317,7 @@ public abstract class EnumSet> extends AbstractSet * or if rest is null * @return an enum set initially containing the specified elements */ + @SafeVarargs public static > EnumSet of(E first, E... rest) { EnumSet result = noneOf(first.getDeclaringClass()); result.add(first); diff --git a/jdk/src/share/classes/javax/swing/SwingWorker.java b/jdk/src/share/classes/javax/swing/SwingWorker.java index 48f2d56bd2b..413f81f9376 100644 --- a/jdk/src/share/classes/javax/swing/SwingWorker.java +++ b/jdk/src/share/classes/javax/swing/SwingWorker.java @@ -404,6 +404,7 @@ public abstract class SwingWorker implements RunnableFuture { * @see #process * */ + @SafeVarargs protected final void publish(V... chunks) { synchronized (this) { if (doProcess == null) { diff --git a/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java b/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java index 583352918e4..2988521f133 100644 --- a/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java +++ b/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java @@ -120,6 +120,7 @@ public abstract class AccumulativeRunnable implements Runnable { * {@code Runnable} for execution. * @param args the arguments to accumulate */ + @SafeVarargs public final synchronized void add(T... args) { boolean isSubmitted = true; if (arguments == null) {