RFR-8148748: ArrayList.subList().spliterator() is not late-binding

Paul Sandoz paul.sandoz at oracle.com
Mon Feb 8 15:10:28 UTC 2016


> On 8 Feb 2016, at 15:53, Tagir F. Valeev <amaembo at gmail.com> wrote:
> 
> Hello!
> 
> Sorry, I don't understand how passing AbstractList would help.

Yeah, sorry ignore what i sad about AbstractList, was not thinking properly in my attempt to unify.


> We
> still need direct access to the elementData array of the original
> ArrayList for efficiency, and this field is also late-binding, so we
> need to have a reference to the ArrayList as well even in SubList
> case. SubList reference is also necessary, because we need to get size
> and modCount from it. So we have need both ArrayList and SubList and
> cannot replace them with single AbstractList. Note that my current
> implementation does not introduce new virtual calls at all.
> 
> Surely it's possible to duplicate the Spliterator implementation. I
> have some doubts that it's reasonable, because this would increase the
> maintenance cost. Current Spliterator does the job pretty well for
> both SubList and original ArrayList. Nevertheless, if you think it's
> better I can create separate class (ArrayListSubListSpliterator?
> ArrayListSubSpliterator? SubListSpliterator?) leaving the original
> ArrayListSpliterator as is.
> 

Re: maintenance, ordinarily i would agree with you, but ArrayList is kind of special being probably the most used collection class. Using an anon-impl for SubList.spliterator seem ok in that respect.


> I'm just worrying a little that my changes might conflict with Ivan
> Gerasimov's pending 8079136 issue, so probably it would be better to
> wait till it's reviewed and pushed…
> 

Yes, i was wondering about that too.

Paul.




More information about the core-libs-dev mailing list