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 ?

[207 byte] By [sagar_lokea] at [2007-11-27 10:39:07]
# 1

They are managd by the VM. They are outside the Java language.

jverda at 2007-7-28 18:59:03 > top of Java-index,Java Essentials,Java Programming...
# 2

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

jverda at 2007-7-28 18:59:03 > top of Java-index,Java Essentials,Java Programming...
# 3

though vtables are used by sun's implementation, per the java specification, they are not absolutely required in other implementations.

petes1234a at 2007-7-28 18:59:03 > top of Java-index,Java Essentials,Java Programming...
# 4

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..

petes1234a at 2007-7-28 18:59:03 > top of Java-index,Java Essentials,Java Programming...