2

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?

wei
  • 6,629
  • 7
  • 40
  • 52

2 Answers2

2

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.

wei
  • 6,629
  • 7
  • 40
  • 52
  • Any citations?.This link(http://en.wikipedia.org/wiki/Late_binding#Late_binding_in_Java) say it is implemented by reflection API, though without any details or citations. – Tony Dec 06 '14 at 13:37
0

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.

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365