Duplicate :
|
Javac allows to inherit a method with one signature from the superclass and a super interface at the same time. It is also not a problem if this method is protected in the class and is certainly public in the interface - you just have to override it as public in the subclass. But for some unclear reasons using the described class and the interface as the multiple bounds for a generic type doesn't work. Here it the minimal test case: class MyClass { protected void foo() { } } interface MyInterface { public void foo(); } // MixedClass compiles fine class MixedClass extends MyClass implements MyInterface { public void foo() { super.foo(); } } // this doesn't compile wit the message // foo() in MyClass cannot implement foo() in MyInterface // which isn't correct, because it perfectly can do it in the subclass public class GenericProblem<T extends MyClass & MyInterface> { } This problem is reproducible with the latest JDK 7