I have problem with the below code in Java 8. In Java 7, the code works fine but when I changed it to Java 8 it shows this error:
The method mymethod(arg1,context,arg2) is ambiguous for the type Z.
I tried to use AbstractContext<MyModel>
while calling the method, in Eclipse the error disappeared but while compiling it still occurs. Does anyone have any idea what could be wrong?
public interface K<T extends MyModel>{
AbstractContext<T> create(T context, SomeObject arg1, SomeObject1 arg2);
}
public abstract class X {
@Override
public AbstractContext<MyModel> create(final MyModel context,final SomeObject1 arg1,SomeObject2 arg2){
//somelogic
}
protected String mymethod(final SomeObject arg1,
final AbstractContext<MyModel> context, final SomeObject1 arg2){
//some logic
return "test";
}
}
public class Y extends X implements Z<MyModel>{
@Override
public AbstractContext<MyModel> create(final MyModel context,final
SomeObject1 arg1,SomeObject2 arg2){
//somelogic
}
protected String mymethod(final SomeObject arg1,
final AbstractContext<MyModel> context, final SomeObject1 arg2){
return super.mymethod(arg1,context,arg2);
}
}
public class Z extends Y {
protected void somemethod(arg1,context,arg2){
//some logic
this.mymethod(arg1,context,arg2);
}//here error occurs
@Override
protected String mymethod(final SomeObject arg1,
final AbstractContext<MyModel> context, final SomeObject1 arg2){
//some new logic
return "newtest";
}
}