RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map
martinrb at google.com
Wed Nov 29 18:09:49 UTC 2017
Guava's "immutable collections" are very popular
and it's not a good idea to fight their advertised notion of "immutable".
No generic container class can promise s'marks-style immutability (until
valhalla perhaps?) so it's not that useful a concept in this domain.
We like to think of Optional as an immutable value based class but you
can't stop anyone who really wants to mutate the contained element from
creating an Optional<AtomicReference<Object>>
We could do a better job of clarifying consequences of element mutation.
E.g. do we ever say that hash based collections/maps are broken if elements
are ever mutated in such a way that their hash code changes while they are
in the collection/map?
More information about the core-libs-dev