Syntax for calling super

Brian Goetz brian.goetz at oracle.com
Thu Aug 23 06:35:14 PDT 2012


We already considered that one too.

K.default would make sense *if* it were permitted for any class to just 
call directly to the default of any interface method, regardless of 
relationship in the hierarchy.  But instead we chose to follow the 
approach taken by classes; you can only super-call to a method if your 
class (is eligible to) directly override it; it is invisible to everyone 
else.  We chose semantics that are as similar to that as we could get; 
for that reason, we wanted a syntax that was similar too. 
"K.default.m()" seemed likely to surprise people when they found out 
they couldn't call the default for any old K.

On 8/23/2012 1:46 AM, "Zdeněk Troníček" wrote:
> In addition, K.super already means something else:
>
> class A {
>      int x;
> }
>
> class B extends A {
>      int x;
>      class B1 {
>          int x;
>          {
>              System.out.println(B.super.x); // refers to A.x
>              System.out.println(B.super.toString()); // calls A.toString()
>          }
>      }
> }
>
> What about K.default?
>
> Z.
>


More information about the lambda-dev mailing list