Collin Fagan collin.fagan at gmail.com
Mon Dec 19 04:51:51 PST 2011


If you try hard enough, yes. Previous answers to this question indicate
that they don't consider it a big deal and do not expect people to actually
use default methods in such a manor.

On Mon, Dec 19, 2011 at 3:11 AM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> Is it not possible to add state to interface through default methods?
>
>    interface WithFoo
>        int getFoo() default {  return fooMap.get(this);  }
>        void setFoo(int x) default { fooMap.set(this, x); }
>
>    static WeakConcurrentMap fooMap = new ...;
>
> Zhong Yu
>
> On Mon, Dec 19, 2011 at 2:35 AM, Lukas Eder <lukas.eder at gmail.com> wrote:
> >> 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?
> >
> > According to page 42 of the presentation I mentioned, extension
> > methods really *are* an additional means of multiple inheritance,
> > "final" or not. Interfaces already provide multiple inheritance of
> > types, now there'll also be multiple inheritance of "behaviour", or
> > something similar to "stateless traits":
> >
> http://blogs.oracle.com/briangoetz/resource/devoxx-lang-lib-vm-co-evol.pdf
> >
> > Whether "final" is allowed or not is probably not very important to
> > that discussion.
> >
> > Regards,
> > Lukas
> >
>
>


More information about the lambda-dev mailing list