default keyword is harmful was Re: Default method survey results

Jason Schroeder shrode at
Fri Aug 17 12:13:13 PDT 2012

> Another way to see the problem is to think about the reflection API.
> Should we have a method getDefaultMethods() in java.lang.Class or a
> isDefault() on j.l.r.Method ?
> I think the answer is no,
> because exactly like their is no way to do the equivalent code of
> super.m() with the reflection API,
> they should be no way to directly call the code of a method in an
> interface (I.super.m()).

Proxy needs to be considered, I think, before I would agree.

I can imagine a need to have an InvocationHandler which desires to use
the implementation of a default method.  Currently, it does not seem
that this is possible.  If the user wants to have a proxy, but opt-out
of proxying a default method, then Proxy starts to behave like it
accepts abstract classes.

Without some "superinterface method implementation" hint in the
runtime, it seems that the solution is to use an abstract class proxy
generator instead of an interface proxy.

(I am additionally curious about backwards compatibility of
InvocationHandler implementations and default methods.  Does the
generator base any decisions based on the classfile version?)

More information about the lambda-dev mailing list