-->

How is dynamic binding implemented in Java?

2019-02-15 14:41发布

问题:

I am aware that in C++, there is a virtual pointer in each instance pointing to a virtual table. But how is dynamic binding implemented in Java?

回答1:

I guess I will answer my own question. Basically, an object stores a reference to its class object, where the dynamic binding will be forwarded from an object to.



回答2:

Just to be picky, it's a real pointer to a real table of virtual functions, hence the name "virtual function table," often abbreviated as "vft". It is also commonly abbreviated "vtbl" which doesn't help matters.

Java probably does something fairly similar.