Syntax for calling super
Peter Levart
peter.levart at marand.si
Tue Aug 28 08:04:59 PDT 2012
On Monday, August 27, 2012 12:19:09 PM Dan Smith wrote:
> > What about if there are several outer classes that all directly implement
> > K and you don't want to choose the innermost?
>
> There is no feature (in the current JSR 335 spec) to refer to a
> superinterface method of an enclosing instance. The rule for 'Foo.super'
> is that 'Foo' must refer to either a lexically enclosing class name or a
> direct superinterface of the immediately enclosing class. Otherwise, it's
> an error.
Luckily there is a work-around when you put it all together :-)
public class Outer implements K {
@Override
public void m() {
Runnable K_super_m = K.super::m;
new K()
{
@Override
public void m()
{
K_super_m.run();
}
}.m();
}
}
Regards, Peter
More information about the lambda-dev
mailing list