javaooppolymorphism

How polymorphism is implemented in java?


In Java all public non static methods are virtual. This means that which method to call is decided on run time(dynamic binding). In C++ virtual functions (dynamic binding) is implemented by using vpointer and vtable. I want to know that how this is implemented by Java. Does Java also use vpointer and vtable like C++ or some other technique to know which method to call on run time?


Solution

  • vtables, as described at https://wiki.openjdk.org/display/HotSpot/VirtualCalls

    [edit Tomasz makes a good point in the question comments - this is for Oracle's hotspot]