Defender methods and compatibility

Brian Goetz brian.goetz at oracle.com
Sun Nov 28 16:35:17 PST 2010


> I'm not in favor to use the default methods to disambiguate when
> there are several extension methods. As Neal said, the default method
> is part of the implementation.

I disagree with Neal's interpretation.  I think the body of the default is an implementation detail, but the identity of the default is not.  

> I propose to use the declaring type instead of the default method
> to disambiguate.

Your rules below all produce the same results as the currently described rules.  Can you offer an example where your rules produce a different result?  

> Let's take several examples:
> 
>   interface Foo {
>     extension void m() default Foos.m;
>   }
>   interface Bar {
>     extension void m() default Bars.m;
>   }
>   class A implements Foo, Bar { }
> 
>   A::m can be Foo::m or Bar::m, because
>   there is no most specific type between Foo and Bar,
>   a call to A::m should throw a linkage error.
> 
>   interface Foo {
>     extension void m() default Foos.m;
>   }
>   interface Bar extends Foo {
>     extension void m() default Bars.m;
>   }
>   class A implements Foo, Bar { }
> 
>   A::m can be Foo::m or Bar::m, because
>   Bar is a sutype of Foo, a call to A::m will
>   call the default method of Bar::m, Bars.m.
> 
>   interface Foo {
>     extension void m() default Foos.m;
>   }
>   interface Bar extends Foo {}
>   interface Baz extends Foo { }
>   class A implements Bar, Baz { }
> 
>   A::m can be Foo::m or Foo:m, so a call to
>   A::m will call Foos.m.
> 
>   Rémi
> 
> 



More information about the lambda-dev mailing list