Skip to Main Content

Inheritance for default and abstract methods from generic interface

3049833Oct 14 2015 — edited Oct 14 2015

According to (Inheriting Methods with Override-Equivalent Signatures)

If an interface I inherits a default method whose signature is override-equivalent with another method inherited by I, then a compile-time error occurs. (This is the case whether the other method is abstract or default.)

The following code compiles (javac 1.8.0_60) without errors. Is this a correct behaviour?

interface A {
    void foo(String x);

interface B<T> extends A {
    default void foo(T x) {}

interface I extends A, B<String> { } // No errors.
Post Details
Added on Oct 14 2015
1 comment