Public defender methods and static inner classes in interfaces?
Reinier Zwitserloot
reinier at zwitserloot.com
Tue Aug 31 19:48:51 PDT 2010
Nice solution. That still depends on the question: Does the default method
have to be visible and/or accessible from the caller? If yes, then a
package-private class won't work.
--Reinier Zwitserloot
On Wed, Sep 1, 2010 at 4:45 AM, Andrew Thompson
<lordpixel+lamda-dev at mac.com<lordpixel%2Blamda-dev at mac.com>
> wrote:
>
> On Aug 24, 2010, at 6:25 AM, Reinier Zwitserloot wrote:
>
> > The conclusion of some was that this pattern will be rather common,
> whether
> > encouraged or not, and this has in fact been used as an argument to allow
> > specifying the default implementation directly on an interface method,
> > because this pattern has an ugly wart in it: The inner class must
> > necessarily be public, and is thus visible (because all members of an
> > interface are forced public). Making implementation details visible is
> bad
> > API design.
>
>
> Will the following compile in the prototype, assuming the whole thing is
> placed in Example.java?
>
> public interface Example {
> public extension void method(Object parameter) default Trait.method;
> }
>
> class Trait {
> public void method(Example outer, Object parameter) {
>
> }
> }
>
> People often forget Java allows multiple non-public types in a compilation
> unit (File).
>
> So this at least pushes the implementation to be package private.
>
> Personally I think the body should be allowed inline with the above as the
> de-sugaring.
>
>
> AndyT (lordpixel - the cat who walks through walls)
> A little bigger on the inside
>
> (see you later space cowboy, you can't take the sky from me)
>
>
>
More information about the lambda-dev
mailing list