Compilation of lambda in an interface, do we have a plan ?
robert.field at oracle.com
Wed May 22 13:49:26 PDT 2013
On 05/22/13 12:05, Brian Goetz wrote:
>>> Making interface lambda methods static where possible was done in
>>> lambda weeks back.
>> It depends what you mean by 'where possible', i.e. where you draw the
>> As far as I understand, we only need to make the lambdas that do a super
>> not all lambdas that capture 'this'.
>> I'm not very comfortable to have instance default method in interface
>> when a static method can work
>> (even if it's not very rational, private methods are no more overridable
>> that static ones).
> The eventual (for Java SE 8) outcome will be that we do the same thing
> in classes and interfaces. But there were some implementation
> difficulties that have slowed our movement in this direction, and
> they're being ironed out.
We do the same thing in classes and interfaces now (save for the public
default method work-around). Same logic. What Remi is saying is that
using "this" doesn't NECCESSARILY require one to make it an instance
method, we could translate the "this" and add a parameter to the
static. Same with accessable references to instance methods/fields,
with a little more complex translation. Note there can be inner classes,
and .... In each case the complexity goes up, and we always have to
make some of them instance methods. As we try to in general, we took
the simpler route, in cases where the "best" route can still be
implemented in the future.
Given that the instance methods (including defaults) WILL be private.
What is the source of your discomfort?
More information about the lambda-spec-experts