How is dynamic binding implemented in Java?

2019-02-15 14:52发布

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?

2条回答
劫难
2楼-- · 2019-02-15 15:28

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.

查看更多
别忘想泡老子
3楼-- · 2019-02-15 15:30

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.

查看更多
登录 后发表回答