RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map
Alan.Bateman at oracle.com
Thu Sep 21 12:42:25 UTC 2017
On 21/09/2017 01:02, Stuart Marks wrote:
> (also includes 8184690: add Collectors for collecting into
> unmodifiable List, Set, and Map)
> Hi all,
> Please review the following changeset with specification changes to
> support the following:
> * new List.copyOf(), Set.copyOf(), and Map.copyOf() "copy factory"
> * new Collectors.toUnmodifiableList, Set, and Map methods
> * specification revisions to provide clearer definitions of "view"
> collections, "unmodifiable" collections, and "unmodifiable views"
> The specification text has walked back most uses of "immutable",
> changing many occurrences to "unmodifiable". (People thought that
> putting a mutable object into an immutable collection would somehow
> magically make the whole thing immutable. Also, there was continual
> confusion with "immutable persistent" data structures.)
> This review is mainly about specification. Minimal implementations are
> included, but no tests. Those will come later.
I read through the updated/new definitions and they read well.
For the copyOf methods then I can't immediately tell from the javadoc if
the given collection can contain null elements. Taking List.copyOf as an
example where coll may be null or it may contain null elements. The
javadoc does link to "Unmodifiable lists" where it specifies the
characteristics of the lists returned by the static factory methods -
these include disallowing null elements. So I think this needs to be
Minimal implementation is okay to get started but what is the reason not
to include some basic tests?
More information about the core-libs-dev