Syntax for calling super

Peter Levart peter.levart at marand.si
Mon Sep 3 05:11:57 PDT 2012


On Monday, August 27, 2012 12:19:09 PM Dan Smith wrote:
> > public class A implements J, K {
> >
> > 
> >    public void m() { ... }
> > 
> >    class B implements K {
> >        public void m() {
> >            super.m(); // is the same as
> >            this.super.m(); // and in this example the same as more specific
> >            K.super.m(); // which is the same as
> >            this.K.super.m(); // but
> > 
> >            A.this.K.super.m(); 
> >           // can be used to select A outer instance's K superinterface method 
> >       }
> >    }
> >
> > }
> 
> To avoid a tangled mess, ideally this syntax would work so that the way to
> refer to the a super method of an enclosing class were:
> 
> Outer.this.super.m();
> 
> rather than:
> 
> Outer.super.m();
> 
> Unfortunately, that ship has sailed...

You could make Outer.super.m() a deprecated syntax for calling super on an outer instance (emit a warning) and offer alternative Outer.this.super.m() as a replacement.

In a distant future (JDK10 or 11), the deprecated syntax would then be removed and Type.super.m() used exclusively for calling super interface methods...

Regards, Peter



More information about the lambda-dev mailing list