Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Behaviour of default methods in ECJ

Hi Everyone,

We have found inconsistent behaviour of method resolution between
javac compiler and ECJ. We believe this is a bug in the ECJ compiler.

Here’s the problematic program:

interface A1 { int m(); }
interface B1 { default int m() { return 0; }}
interface M1 extends A1, B1 {} //rejected by both javac and ECJ

interface B2 extends B1 { int m(); }
interface B3 extends B2 { default int m() {return 1;}}
interface M2 extends A1, B3 {} //rejected by javac, but accepted by ECJ

The ECJ compiler we are using is :  ecj-4.5.1.jar
The javac compiler we are using is : javac 1.8.0_40

Here interface M1 is both rejected by javac and ECJ, the error message says
that the default method m() in B1 conflicts with the abstract method m() in
A1. Note that, in this case A1 and B1 are unrelated types.

Now the weird thing happens with M2, which extends A1 and B3 (also unrelated
types). M2 is rejected by javac (as we would expect) but accepted by ECJ.

Best Regards,

Bruno, Haoyuan, Marco and Yanlin


Back to the top