SAM types and functions

Alex Blewitt alex.blewitt at gmail.com
Wed Dec 16 01:06:33 PST 2009


On Thu, Dec 10, 2009 at 10:38 PM, Alex Blewitt <alex.blewitt at gmail.com> wrote:
>> Many existing Java libraries define interfaces which declare just one
>> method
>> or abstract classes which declare just one abstract method (so-called
>> “SAM” types).
>> A function of appropriate type is converted to an anonymous instance ...
> I'm not sure this is needed in the general case ...

I did a scan of the Java class libraries (those with java.* or
javax.*) - there's 100 interfaces and 220 classes which fall into this
definition. Quite a lot more than I expected :-) And I can see where
this would be useful, provided that we can deal with the ambiguous
cases (e.g. as proposed earlier, with an explicit cast).

Alex


More information about the lambda-dev mailing list