Spliterators of iterators

Martin Buchholz martinrb at google.com
Mon Jun 15 16:34:47 UTC 2015


Staring at LinkedTransferQueue.java, I see:

                    return Spliterators.spliterator
                        (a, 0, i, (Spliterator.ORDERED |
                                   Spliterator.NONNULL |
                                   Spliterator.CONCURRENT));

but ... that's a spliterator over an immutable array, so shouldn't we have
IMMUTABLE instead of CONCURRENT?

Looking further, I see ArraySpliterator requires its input array to be
unmodified during operation

         * @param array the array, assumed to be unmodified during use

("assumed" is weird in javadoc.  maybe "required"?)

but ArraySpliterator does not include IMMUTABLE in characteristics, even
though Arrays.spliterator does.

I suggest fixing all these array spliterator characteristics to always
report IMMUTABLE and never report CONCURRENT, and to document this fact, as
we already do with SIZED and SUBSIZED.



More information about the core-libs-dev mailing list