<Swing Dev> RFR JDK 8: 8022190 Fix varargs lint warnings in the JDK
Alexander Scherbatiy
alexandr.scherbatiy at oracle.com
Mon Aug 5 12:07:36 UTC 2013
The fix looks good for me.
Thanks,
Alexandr.
On 8/5/2013 5:04 AM, Joe Darcy wrote:
> Hello,
>
> Please review this fix for
>
> 8022190: Fix varargs lint warnings in the JDK
> http://cr.openjdk.java.net/~darcy/8022190.0/
>
> Full patch below.
>
> While the @SafeVarargs annotation generally suppresses compiler
> warnings about methods, when the varargs lint option is enabled, javac
> does some checking of the body to see if it is indeed safe. If it
> cannot be proven safe, javac will issue a warning.
>
> The the four cases below, javac is unable to determine that the
> methods are safe. The @SuppressWarnings("varargs") annotations added
> below help javac out in this regard.
>
> Thanks,
>
> -Joe
>
> diff -r 33617583c545 src/share/classes/java/util/stream/Stream.java
> --- a/src/share/classes/java/util/stream/Stream.java Wed Jul 31
> 10:53:33 2013 -0700
> +++ b/src/share/classes/java/util/stream/Stream.java Sun Aug 04
> 18:02:15 2013 -0700
> @@ -827,6 +827,7 @@
> * @return the new stream
> */
> @SafeVarargs
> + @SuppressWarnings("varargs") // Creating a stream for an array is
> safe
> public static<T> Stream<T> of(T... values) {
> return Arrays.stream(values);
> }
> diff -r 33617583c545 src/share/classes/javax/swing/SwingWorker.java
> --- a/src/share/classes/javax/swing/SwingWorker.java Wed Jul 31
> 10:53:33 2013 -0700
> +++ b/src/share/classes/javax/swing/SwingWorker.java Sun Aug 04
> 18:02:15 2013 -0700
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights
> reserved.
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> *
> * This code is free software; you can redistribute it and/or modify it
> @@ -405,6 +405,7 @@
> *
> */
> @SafeVarargs
> + @SuppressWarnings("varargs") // Passing chunks to add is safe
> protected final void publish(V... chunks) {
> synchronized (this) {
> if (doProcess == null) {
> diff -r 33617583c545
> src/share/classes/sun/reflect/annotation/AnnotationParser.java
> --- a/src/share/classes/sun/reflect/annotation/AnnotationParser.java
> Wed Jul 31 10:53:33 2013 -0700
> +++ b/src/share/classes/sun/reflect/annotation/AnnotationParser.java
> Sun Aug 04 18:02:15 2013 -0700
> @@ -88,6 +88,7 @@
> * @param selectAnnotationClasses an array of annotation types to
> select when parsing
> */
> @SafeVarargs
> + @SuppressWarnings("varargs") // selectAnnotationClasses is used
> safely
> static Map<Class<? extends Annotation>, Annotation>
> parseSelectAnnotations(
> byte[] rawAnnotations,
> ConstantPool constPool,
> diff -r 33617583c545
> src/share/classes/sun/swing/AccumulativeRunnable.java
> --- a/src/share/classes/sun/swing/AccumulativeRunnable.java Wed Jul
> 31 10:53:33 2013 -0700
> +++ b/src/share/classes/sun/swing/AccumulativeRunnable.java Sun Aug
> 04 18:02:15 2013 -0700
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights
> reserved.
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> *
> * This code is free software; you can redistribute it and/or modify it
> @@ -121,6 +121,7 @@
> * @param args the arguments to accumulate
> */
> @SafeVarargs
> + @SuppressWarnings("varargs") // Copying args is safe
> public final synchronized void add(T... args) {
> boolean isSubmitted = true;
> if (arguments == null) {
>
More information about the swing-dev
mailing list