RFR JDK-8010096 : Initial java.util.Spliterator putback

Paul Sandoz paul.sandoz at oracle.com
Thu Mar 28 08:59:52 PDT 2013



Spec diff:
Relevant JavaDoc generated from lambda repo (required for viewing @apiNote, @implSpec, @implNote declarations):

Note: some of the JavaDoc generated from the lambda repo may contain additional methods or specification that is relevant to the stream framework.


To enable bulk operations, in parallel, on a data source it is required that such a source efficiently partition itself into smaller parts, where parts are processed concurrently, and each part is traversed sequentially.
A new data interface is required that defines the contract for efficient partitioning and traversal.
Collections need to implement that new data interface so the JSR-335 stream library can support bulk operations on common collection implementations, such as List/Set and arrays, in addition to other forms of data source e.g. third party collections.

java.util.Spliterator, and primitive specializations of, is the key data interface that enables partitioning and traversal. JSR-335 java.util.stream.Stream instances will be constructed from spliterators.
Collection is extended to define the default method spliterator(). Implementations are expected to override this method. The default implementation utilizes the collection's iterator and size to provide a spliterator implementation that permits limited parallism.  Default overriding implementations are also provided for List, Set and SortedSet that support additional properties associated with those collections.
Together with Spliterator some implementations are provided for creating Spliterator instances from data sources that are iterators and arrays.

Note: Optimal spliterator implementations for many collection implementations in java.util and java.util.concurrent are present in the lambda repository and will duly make their way into TL after this webrev has been reviewed and pushed.


Once this webrev is reviewed and pushed then the Stream API can follow, and then the fun really begins :-)

The class com.sun.tools.jdi/EventSetImpl has been modified but is likely to change when spliterator implementations are pushed. This class cannot decide if it wants to be a List or a Set!! The compiler cannot work out if the default implementation of spliterator() for List or Set should apply. When the concrete collection implementations of spliterator arrive this class will not need to implement spliterator() and will inherit the implementation from ArrayList (implementations on classes always win over default implementations on interfaces).

Unfortunately to build TL with this patch applied requires one also apply:


Which i suspect was lost in the wash and should have been pushed to TL a while ago. Will follow up with Robert on that one.

A JPRT of TL with both patches applied did not show any abnormal test failures.


More information about the lambda-dev mailing list