Suppose I have a class Foo like so:
public class Foo<T> {
protected T invoke(Object... args);
}
Now suppose I add this:
public class Bar<T, Arg> extends Foo<T> {
public T invoke(Arg arg);
}
Does this mean that I cannot create a Bar<T, Object[]> since it would create two invoke() methods with "essentially" the same signature? Or would Bar.invoke() safely hide Foo.invoke() in this case (as Bar.invoke() is, runtime-wise, taking Object rather than the Object[] of Foo.invoke())?
Related to this: is forwarding Bar.invoke() to Foo.invoke() safe and fine?
Bar.invokedoes not overrideFoo.invoke. If you call justbar.invokewith no arguments you'll get thefoo.invokecalled.But you'll get a compile time error (
reference to invoke is ambiguous) if you construct aBarobject:Bar<Object, Object[]> bar = new Bar<Object, Object[]>()and then invokebar.invoke(new Object[]{})because the 2 invoke methods have the same erasure at runtime.