Project Coin: Safe Varargs in JDK Libraries
By Darcy-Oracle on Jan 24, 2011
Back for JDK 7 build 123, the language support for the Project Coin's safe varargs feature was pushed; the time has come to update the libraries to take advantage of this feature.
Following the same general methodology used to systematically flush out types that should be made
AutoCloseable, I wrote an annotation processor to identify candidate varargs methods and constructors where adding a
@SafeVarargs annotation might be appropriate.
Several JDK library methods were known candidates for @SafeVarargs; running the annotation processor found another one.
The complete list of methods to be annotated in a
javax.\* package is:
public static <T> List<T> java.util.Arrays.asList(T... a)
public static <T> boolean java.util.Collections.addAll(Collection<? super T> c, T... elements)
public static <E extends Enum<E>> java.util.EnumSet<E> EnumSet.of(E first, E... rest)
protected final void javax.swing.SwingWorker.publish(V... chunks)
After this update, many fewer spurious unchecked warnings will be reported when calling core library classes.