RFR: 8193031: Collections.addAll is likely to perform worse than Collection.addAll [v2]

Rémi Forax github.com+828220+forax at openjdk.java.net
Thu Dec 17 10:52:57 UTC 2020


On Thu, 17 Dec 2020 10:45:17 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/Collections.java line 5589:
>> 
>>> 5587:      */
>>> 5588:     @SafeVarargs
>>> 5589:     @SuppressWarnings("varargs")
>> 
>> I don't think you need a SuppressWarnings here
>
> Hi, without this I get failed build:
> Compiling 3057 files for java.base
> Compiling 89 properties into resource bundles for java.desktop
> 
>         return c.addAll(Arrays.asList(elements));
>                                       ^
> error: warnings found and -Werror specified
> 1 error
> 1 warning
> make[3]: *** [/home/s.tsypanov/IdeaProjects/jdk-github/build/linux-x86_64-server-release/jdk/modules/java.base/_the.java.base_batch] Error 1
> CompileJavaModules.gmk:604: recipe for target '/home/s.tsypanov/IdeaProjects/jdk-github/build/linux-x86_64-server-release/jdk/modules/java.base/_the.java.base_batch' failed
> make[2]: *** [java.base-java] Error 2
> make[2]: *** Waiting for unfinished jobs....
> make/Main.gmk:193: recipe for target 'java.base-java' failed

ok, it means there is a bug in the compiler, the analysis done for unsafe varargs (with -Xlint:varargs) doesn't check that the called method (here Arrays.asList()) is tagged with @SafeVarargs.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1764


More information about the core-libs-dev mailing list