Will JDK 8 support SAM that is Abstract Class ?
Kevin Bourrillion
kevinb at google.com
Mon Nov 5 08:41:39 PST 2012
I was initially pro-abstract-class-support, but after taking a hard look at
just how often such a feature is really needed I changed my mind.
If abstract classes were supported, there would be a magical hidden
invocation of user code here:
SomeType x = () -> 1;
... namely, the SomeType constructor. That constructor could do anything,
including throw checked exceptions -- this is pretty surprising and goes
against the "feel" of lambda expressions. And note there'd be no way to
invoke a constructor that had parameters anyway.
When we really must extend a SAM abstract class, we'll just have to
continue to use an anonymous class, and that's fine.
--
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
More information about the lambda-dev
mailing list