RFR(m): 8139233 add initial compact immutable collection implementations

Peter Levart peter.levart at gmail.com
Wed May 4 21:58:13 UTC 2016

On 05/04/2016 05:25 PM, Stephen Colebourne wrote:
> I disagree with altering the iteration order. Guava's ImmutableSet and
> ImmutableMap have reliable iteration specified to match creation
> order. This aspect of the design is very useful.
> Stephen

Are they also O(1) on lookup at the same time?

Altering iteration order from VM run to VM run is a double-edged sword. 
I can understand that by doing so, programs written to depend on 
iteration order are practically not possible. In the absence of such 
"randomization", a simple change of hashCode algorithm of some element 
of the collection (could be a user class) could break the program. But 
as Alan pointed out it is also harder to reproduce problems that way. 
OTOH one might argue that randomization actually prevents such problems 
to appear in the first place. It forces the programs to be written in a 
way so that they don't depend on any particular iteration order as it 
uncovers any potential problems dependent on iteration order early in 
the development phase.

Regards, Peter

More information about the core-libs-dev mailing list