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

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Fri Dec 18 14:37:25 UTC 2020


On Thu, 17 Dec 2020 11:07:55 GMT, Rémi Forax <github.com+828220+forax at openjdk.org> wrote:

>> Should I then wait for the fix of that bug to remove `@SupressWarnings`?
>
> I don't think so, the code is fine, for me.

I've looked into `com.sun.tools.javac.comp.Check` and it seems the warning is produced here:
        @Override
        public void warn(LintCategory lint) {
            boolean warned = this.warned;
            super.warn(lint);
            if (warned) return; // suppress redundant diagnostics
            switch (lint) {
                case UNCHECKED:
                    Check.this.warnUnchecked(pos(), Warnings.ProbFoundReq(diags.fragment(uncheckedKey), found, expected));
                    break;
                case VARARGS:
                    if (method != null &&
                            method.attribute(syms.trustMeType.tsym) != null &&
                            isTrustMeAllowedOnMethod(method) &&
                            !types.isReifiable(method.type.getParameterTypes().last())) {
                        Check.this.warnUnsafeVararg(pos(), Warnings.VarargsUnsafeUseVarargsParam(method.params.last()));
                    }
                    break;
                default:
                    throw new AssertionError("Unexpected lint: " + lint);
            }
        }
Can we somehow read `@SaveVarargs` from signature of `Arrays.asList()` to avoid the warning?

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

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


More information about the core-libs-dev mailing list