Problem of defender methods with generic methods

Alex Buckley alex.buckley at oracle.com
Tue Nov 16 10:58:21 PST 2010


On 11/15/2010 11:35 PM, Peter Levart wrote:
> Why are extension methods so special? Wouldn't also other kinds of
> methods and class constructors benefit from such a feature? Take for
> example the interface SortedSet and one of it's implementations:
> TreeSet. It would be desirable that constructors not taking a
> Comparator restrict type variable to a subtype of Comparable.

JSR 14 designed generics in a particular way, such as the bound of a 
type variable having certain restrictions. We do not re-open the design 
of a former JSR lightly. Extension methods (or rather, the library 
evolution that needs extension methods) may provide a strong enough reason.

Alex


More information about the lambda-dev mailing list