Q: List.of(E... elements) specification with regards to underlying array updates

Eirik Bjørsnøs eirbjo at gmail.com
Tue Sep 2 12:00:56 UTC 2025


On Tue, Sep 2, 2025 at 1:46 PM Eirik Bjørsnøs <eirbjo at gmail.com> wrote:

> Interestingly, List.copyOf [4] explicitly specifies that modifications
> to the given Collection are not reflected in the returned List. (Even
> when this may be inferred from the method name!). This prose is what I
> feel may be missing from List.of(E... elements).

TLDR:

I think my long-winded question boils down to:

Should we add something like the following to List.of(E... elements):

     * If the given array is subsequently modified, the returned List will not
     * reflect such modifications.

This would clarify this aspect and provide parity with List.copyOf.

Eirik.


More information about the core-libs-dev mailing list