Lets suppose I have a ComponentBase
class, who is child of ObjectContextDecorator
and grandchild of ObjectContext
.
public class ComponentBase extends ObjectContextDecorator {
}
public class ObjectContextDecorator extends ObjectContext {
public void set(String objectTypePath, String characteristicName, Object value) {
//...
}
}
public class ObjectContext {
public void set(String characteristicName, Object value, boolean forced) {
//...
}
}
The set
methods on ObjectContextDecorator
and ObjectContext
are very simillar. Consider this sample code:
ComponentBase base = new ComponentBase();
base.set(""OTM4E_EFFLEVEL"", ""IE1 / STD"", true);
Both methods' signatures fit the one being called correctly. I am not able to change the methods' signatures since it is not my code.
How does the compiler know which method I intended to call?
I know that on the IDE you can point out which method you are actually intending to call, but in this situation, I am using a class loader to load a class which has a method containing the sample code.
String, String, boolean
. The most-specific method will be called. This is all in the JLS. – Lithotrity"this"
) – Deservedly