I have superclass Foo. And a class Bar extending it.
public class Bar extends Foo
Function in Foo:
protected void saveAll(C
Due to the type erasure feature of Java, the JVM will not be able to know whether it is the method that has the parametrized type MyClass or the first one that should be called.
If possible or applicable, the most commonly used pattern I've seen to avoid this is to change the class Foo to have a parametrized type as well:
public class Foo {
protected void saveAll(Collection many) {}
}
and then have Bar simply implement Foo for your specific type:
public class Bar extends Foo {
public void saveAll(Collection many) {
super.saveAll(many);
}
}