RFR: 8215995: Add specialized toArray methods to immutable collections

Stuart Marks stuart.marks at oracle.com
Tue Jan 8 02:44:41 UTC 2019

> This is one of Stuart's designs

Trying to blame it all on me, aren't you? :-)

Overall the changes look good.

I can't really speak to how to improve the loops in certain circumstances (the 
"tricky circular array traversal code from ArrayDeque" as Martin puts it). But I 
observe that moving the randomization to iteration has started to increase the 
complexity of the code. I understand why we did this, but it's starting to look 
like we might want to refactor the various loops into a single internal 
"iterator" to avoid duplicating it all over the place. Perhaps for a future 

I observe that the serialized forms aren't randomized. When the storage order 
was randomized, the serial form was also randomized. But now that randomization 
is done during iteration, the serialized forms are fixed. Hmmm. Not sure what I 
think about that.


More information about the core-libs-dev mailing list