Virtual Tables in java ! ! !
Is there concept of Virtual Table in java like C++ ? If yes, how they are maintained internally ? Who is maintaining them ? where they are maintained ? are they inherited from java.lang.object class ?
Is there concept of Virtual Table in java like C++ ? If yes, how they are maintained internally ? Who is maintaining them ? where they are maintained ? are they inherited from java.lang.object class ?
The VM spec will tell you what's required. Evertying else is up to the individual implementations.
http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html
though vtables are used by sun's implementation, per the java specification, they are not absolutely required in other implementations.
correction of my post above:
In the first edition of Chapter 3, Structure of the Java Virtual Machine:
http://java.sun.com/docs/books/jvms/first_edition/html/Overview.doc.html
In particular, look at section 3.7, Representation of Objects. It states:
The Java Virtual Machine does not require any
particular internal structure for objects. In Sun's
current implementation of the Java Virtual Machine, a
reference to a class instance is a pointer to a handle
that is itself a pair of pointers: one to a table
containing the methods of the object and a pointer to
the Class object that represents the type of the
object, and the other to the memory allocated from
the Java heap for the object data.
Other Java Virtual Machine implementations may
use techniques such as inline caching rather than
method table dispatch, and they may or may not use
handles.
The second edition as referenced by jverd is much more sparce. It simply states:
The Java virtual machine does not mandate any particular internal structure for objects.
The book mark there states:
In some of Sun's implementations of the Java virtual machine, a
reference to a class instance is a pointer to a handle that is itself a pair
of pointers: one to a table containing the methods of the object and a
pointer to the Class object that represents the type of the object, and
the other to the memory allocated from the heap for the object data..