Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Inheritance for default and abstract methods from generic interface

3049833Oct 14 2015 — edited Oct 14 2015

According to https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.4.1.3 (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.

Comments

Post Details

Added on Oct 14 2015
1 comment
464 views