Is Comparator SAM interface ?

Joshua Bloch jjb at google.com
Sun Jan 10 22:05:18 PST 2010


Artur,

I came up with the term SAM-type, suppose I suppose I get to put my two
cents in: SAM is "single abstract method," and the equals method
in  java.util.Comparator is effectively concrete. The technical details are
a bit more complicated.  If you look in JLS3 9.2, you'll see that
*every *interface
with no explicit superinterface inherits lots of methods from Object.  But
this just means that users of the interface get to call those methods; not
that implementers of the interface have to implement them. The net of the
net is that Comparator *is *a SAM type, and if it isn't the case according
to the current definition, then we have to tweak the definition.

        Josh

On Sun, Jan 10, 2010 at 10:02 AM, Artur Biesiadowski <abies at adres.pl> wrote:

> Hello,
>
> For the function conversion, straw-man proposal is expecting interfaces
> defining just one method. It might require wording differently - if read
> literally, java.util.Comparator is not suitable for function conversion,
> because it restates 'equals' in the interface in addition to compare.
> Same goes for Predicate in google collections and probably some other
> classes in different libraries.
>
> Regards,
> Artur Biesiadowski
>
>


More information about the lambda-dev mailing list