List of all default methods

Brian Goetz brian.goetz at oracle.com
Thu Nov 21 13:49:34 PST 2013


>> to produce a new sorted stream.  To avoid making things more confusing,
>> we followed the guideline of adding in-place mutative methods to the
>> concrete collections, and adding functional / lazy methods to Stream,
>> rather than mixing.
>
> yes, only the problem is, that if we follow that rationale then we have
> to remove dozens of our additions plus, the non-mutating versions would
> not be available on a jvm before 8. Sadly we cannot strictly follow that

Well, you have to decide what is best for *your* users.

>> As a general rule, adding stuff to Iterable is probably going to cause
>> ongoing pain.  Use with care.
>
> Iterable, List, Collection, Map, CharSequence, Enumeration, Set,
> SortedSet, SortedMap, Iterable

Its a spectrum.  Adding methods involves reasoning about the probability 
of collision, and whether the weighted downside of collision is 
outweighed by the upside of the new functionality.  The more widely 
implemented an interface is (Iterable more so than List, List much more 
so than BeanContextServiceProvider), the more likely collision is just 
on a quantitative basis.  The more *abstract* it is, the more likely 
you'll have semantic conflicts.  Both suggest Iterable is about the 
worst interface to choose to "enhance".  (This is why we didn't add 
.stream() to Iterable; we forsaw semantic conflicts.)

In any case, now that we're in the business of evolving interfaces as 
well as classes, I think you can expect some additional conflicts in the 
future.  Not necessarily too many, as we try to have restraint, but its 
going to happen.  Seems it happened once or twice in 8.  It might happen 
a few more times in 9.  You'll just need a plan for dealing with it.



More information about the lambda-dev mailing list