[jsr-335-eg] Default method survey results
Ulf Zibis
Ulf.Zibis at CoSoCo.de
Sun Oct 21 08:49:08 PDT 2012
Am 21.10.2012 16:03, schrieb Brian Goetz:
> Other opinions? For all its faults, is "default" better than "extension"?
Why do we need a keyword at all ?
We now have method bodies in Interface, similar we had long time in abstract Class, but with some
restrictions (which are still not clear to me, is there a comparison document "Interface v.s
Abstract Class methods implementation"?).
Any method in any type of class/interface can be seen as a "default" which is used until it becomes
overridden.
With the extension mechanism of Interface by help of "default methods" in fact we now have
introduced *Multiple inheritance* on implementation level in Java, but through the back door.
So I still would prefer to use abstract Class instead of Interface to extend an existing Interface
in a source compatible way and then to additionally introduce/allow an abstract Class to be
inherited by the 'implements' keyword, which would enable the sophisticated priority rules for
multiple inheritance. In first evolution step, we could restrict these multiple inheritable methods
to not access instance member variables, so they are in fact "static".
And do not forget, we ALREADY HAVE HAD extended Interfaces in the past, e.g. in java.sql package. So
it seems manageable to extend interfaces with the existing tools.
Binary incompatibility is perfectly treated by LinkageError,
Source incompatibility maybe additionally could be treated by introducing a @since annotation in
addition to the homonymous javadoc tag.
-Ulf
More information about the lambda-spec-observers
mailing list