Say
class E extends B {}
class B extends A {}
We have,
B v = new E();
process(v);
We know it is true that,
v.getClass() == E.class
Is there a way to tell the static binding for v is exactly B programmatically?
EDIT: The original idea was to have a one line check for overloaded methods. Something like,
process(A a) {
// ... code for a.processABC();
if (a.getStaticBindingClass() == B.class) { // not a subclass of B
// Additional logic for statical binding case.
...
}
// ... code for a.processDEF();
}
It is possible to introduce process(B b); However, there is lots of copy code from process(A a).