RFR: 8378580: Make ArrayDeque bulk add methods bootstrap-proof
Jason Mehrens
duke at openjdk.org
Tue Feb 24 18:48:09 UTC 2026
On Tue, 24 Feb 2026 15:23:18 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:
> Please review this small change to avoid loading lambda machinery in `ArrayDeque.addAll` and `ArrayDeque(Collection)`.
>
> Core collections like these may be useful in early bootstrap where we want to avoid eager loading of lambda machinery. JDK-8375580 recently showed one example where `URLClassPath` was avoiding these bulk-adding methods exactly to avoid triggering lambdas.
>
> This PR replaces the use of `Collection.forEach` with a plain old for loop.
>
> This was initially discussed here: https://mail.openjdk.org/pipermail/core-libs-dev/2026-February/159362.html
>
> Cleanup, low risk enhancement, `noreg-cleanup`.
If the given collection 'c' is Collections.synchronziedXXX, then simple loop doesn't lock correctly. ForEach and toArray work correctly with that wrapper class.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29894#issuecomment-3954022125
More information about the core-libs-dev
mailing list