Default method survey results

Paul Benedict pbenedict at
Thu Aug 16 10:40:23 PDT 2012

On Thu, Aug 16, 2012 at 12:32 PM, Brian Goetz <brian.goetz at> wrote:
>> Why not get rid of default implementations all together? Allow
>> interfaces to be extended at will and the JVM simply throws a
>> NotImplementedException (ala C# or Apache Commons Lang) if there is no
>> overriding implementation.
> Pushing the problem to runtime is not a good solution; a program that
> compiles should not throw linkage errors.

I am not saying make this a linkage error -- something that would
prevent the class from loading. Make this a runtime exception when you
call a method that has no implementation. I think this is perfectly
reasonable; the analogy is close to throwing
UnsupportedOperationException when a developer doesn't really support
the feature. The JVM can stub this "default implementation" of
throwing an exception.

This won't effect the compiler -- you still have to provide concrete
implementations for all abstract methods when compiling a new. But if
there's an existing library out there that's lagging behind, stub in
the thrown exception.

Now you can allow interfaces to evolve without or without a default
implementation. Forcing an implementation might just be going to
evolve an interface.


More information about the lambda-dev mailing list