please review draft JEP: Convenience Factory Methods for Collections
forax at univ-mlv.fr
Thu Jul 17 01:03:09 UTC 2014
On 07/17/2014 02:46 AM, Stuart Marks wrote:
> Hi all,
> Please review this draft JEP for Convenience Factory Methods for
> Brief background: several times over the years there have been
> proposals to add "collection literals" to the language. The most
> recent round of this was in regard to JEP 186, a research JEP to
> explore this topic. That effort was concluded by Brian Goetz, as
> summarized in this email:
> Essentially, the idea of adding collection literals to the language
> was set aside in favor of adding some library APIs, not entirely
> unlike collection literals, that make it more convenient to create
> collections. That's what this proposal is.
> Share and enjoy,
I think you should say something about the serialization of the
because implementation details like the real class name can leak through
That's why, by example, java.util.Collections.ArrayList (the internal
class of Collections) was never renamed.
Also 5 key/value pairs seems a little bit limited IMO, 7 or 8 will be
better but I suppose you want to use the fact
that because the number of pairs is really small, the algorithm can do a
I think you should add a version that takes two arrays of the same size
(for an (almost) unlimited number of pairs)
with an implementation that clone the two arrays (at least until value
type are implemented).
I think you should also add a default method toImmutable to Set, List
and Map, so one can use HashSet, ArrayList
and HashMap as builder for their immutable counterparts. Otherwise, the
stream integration will be difficult,
i.e. the implementation of Collectors.toImmutableList/Set/Map.
More information about the core-libs-dev