RFR: 8378580: Make ArrayDeque bulk add methods bootstrap-proof

Jason Mehrens duke at openjdk.org
Wed Feb 25 11:04:36 UTC 2026


On Tue, 24 Feb 2026 20:42:03 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> The synchronized wrapper collections clearly specify that the user is responsible for synchronizing any iteration or stream operations on those collections. Then, who is the user in this case? The one creating and passing synchronzed collections around, or do we include any collection in the collections framework?

Using iterator to perform copying has a history of problems. See:
https://bugs.openjdk.org/browse/JDK-6347106 and linked tickets.

My advice is to not undo that ticket.

> 
> To avoid further headscratching about this, perhaps a good old anonymous class would be less risky?
> 
> ```java
> c.forEach(new Consumer<E>() {
>     @Override
>     public void accept(E e) {
>         addLast(e);
>     }
> });
> ```

Yes. Thanks!

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

PR Comment: https://git.openjdk.org/jdk/pull/29894#issuecomment-3955982977


More information about the core-libs-dev mailing list