This problem is probably easiest to describe using the following standalone code. It's cut down as much as possible from a real world example. Basically I'm trying to extend a class and override a method whose implementation has been provided as default method in an interface somewhere in the hierarchy. Trying to call the overridden method via super fails with Cannot directly invoke the abstract method setReadOnly(boolean) for the type HasValue.
The same code compiles fine with OpenJDK 17.
public class TestField
extends
CustomField
{
@Override
public void setReadOnly(boolean readOnly)
{
// Eclipse shows this compile error: Cannot directly invoke the abstract method setReadOnly(boolean) for the type HasValue
super.setReadOnly(readOnly);
}
}
abstract class CustomField
extends
AbstractField
implements
HasValue
{
}
abstract class AbstractField
implements
HasValueAndElement
{
}
interface HasValue
{
void setReadOnly(boolean readOnly);
}
interface HasValueAndElement
extends
HasValue
{
@Override
default void setReadOnly(boolean readOnly)
{
}
}
This problem is probably easiest to describe using the following standalone code. It's cut down as much as possible from a real world example. Basically I'm trying to extend a class and override a method whose implementation has been provided as default method in an interface somewhere in the hierarchy. Trying to call the overridden method via
superfails withCannot directly invoke the abstract method setReadOnly(boolean) for the type HasValue.The same code compiles fine with OpenJDK 17.