RFR(s): 8060192: Add default method Collection.toArray(generator)

David Lloyd david.lloyd at redhat.com
Tue Dec 12 14:18:38 UTC 2017

On Mon, Dec 11, 2017 at 8:00 PM, John Rose <john.r.rose at oracle.com> wrote:
> I submit to you that such a factory is *not* an IntFunction, because
> that only creates half of an array (or 0.01% of one), the empty
> version that needs to be populated.  A natural array factory API
> [...]
> The interface would look something like one of these:
> interface ArrayContent<T> { int size(); T get(int i); }
> interface ArrayContent<T> { int size(); Iterator<T> iterator(); }
> interface ArrayContent<T> { int count(); Stream<T> stream(); }
> interface ArrayContent<T> { Spliterator<T> elements(); } //must be SIZED

Wasn't it suggested somewhat recently that arrays themselves might be
retrofitted with this kind of interface?  It seems like it would make
sense for arrays to be able act as their own factories, bringing the
idea full circle.


More information about the core-libs-dev mailing list