Does java has vtable and vptr like C++? I try to understand the
mechanism java used for dynamic method lookup, but my books don't say.
It's implementation dependent (actually it's implementation dependent in C++
too). The only way you can find out is to read the source for the /particular/
JVM implementation you are interested in.
In point of fact, and as far as I can tell, Sun's current range of JVMs use a
small inline cache at the point-of-call (a type-test and unconditional jump if
the test passes) with a fallback to the horrendously inefficient vtable-based
dispatch if that fails. (That's for optimised code, I have no idea how "eager"
the implementation is to use that optimisation).
Static method dispatch (invokestatic), interface method dispatch
(invokeinterface), and invocation of private methods and super-sends can be,
and have to be, handled differently.
-- chris