final extension methods

Anthony Vanelverdinghe anthony.vanelverdinghe at gmail.com
Sun Dec 18 05:00:07 PST 2011



> Now, as an API designer, I'm particularly interested in the concept of
> virtual extension methods and I was wondering whether you also
> considered to introduce "final" extension methods as opposed to
> "default" ones. For example:
>
> interface A {
>    void a();
>    void b() default { System.out.println("b"); };
>    void c() final { System.out.println("c"); };
> }
These kind of examples make me wonder why you wouldn't just use what 's 
already available:

abstract class A {
     abstract void a();
     void b() { System.out.println("b"); }
     final void c() { System.out.println("c"); }
}

I understand extension methods are vital for evolving interfaces. But in 
my opinion they should be used for just that. If we start adding "final" 
extension methods too, then why not simply introduce multiple 
inheritance straightaway?

Kind regards

   Anthony


More information about the lambda-dev mailing list