FULL PRODUCT VERSION :
/opt/jdk1.7.0/bin/javac -version
javac 1.7.0-ea
Build b134
Error occurs on 32bit and 64 Linux systems
ADDITIONAL OS VERSION INFORMATION :
Linux nodeXYZ 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:21 UTC 2011 i686 GNU/Linux
Linux nodeXYY 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 19:31:57 UTC 2010 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
In java 6 problems were reported with inheritance of multiple interfaces, e. g.
http://bugs.sun.com/view_bug.do;jsessionid=38b12cbe58b2634d7bb6dabb8a42?bug_id=6709429
http://bugs.sun.com/view_bug.do?bug_id=6908259
This problems were solved in Java 7. However, the problem still exists if bounded type parameters are used. The compilation of a methods using bounded type parameters inheriting from two interfaces fails. For details see source code below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
try to compile the source reported below using java 7 (e.g. b134)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
successful compilation
ACTUAL -
compilation fails
ERROR MESSAGES/STACK TRACES THAT OCCUR :
/opt/jdk1.7.0/bin/javac someClass.java
someClass.java:19: types B and A are incompatible; both define x(), but with unrelated return types
public static <M extends A & B> void somePubStatic(M mx)
^
1 error
make: [covar] Error 1 (ignored)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class someClass {
interface Top {
Top x();
}
interface A extends Top {
A x();
}
interface B extends Top {
B x();
}
// caused a compiler error in Java 6,
// but was fixed in Java 7
interface AB extends A, B {
AB x();
}
// causes compiler error in Java 7
public static <M extends A & B> void somePubStatic(M mx)
{
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Interestingly, the above code compiles successfully in Eclipse.