Maurizio Vitale Maurizio.Vitale at esat.kuleuven.ac.be
Mon May 26 02:59:24 PDT 1997

tullmann at facility.cs.utah.edu writes:
 > I've been browsing the Kaffe sources and I have a simple question for
 > anyone: Why is the class of an object stored in its dispatch table?
 > And, not, as I would expect, in the object itself?
 > (Look at kaffe/kaffevm/classMethod.h and include/java_lang_Object.h)
 > Just curious,

Don't know anything in particular about Kaffe internals, but I would
guess it's done for saving memory: every object needs a pointer
to the dispatch table anyhow and the same dispatch table can be shared 
by all objects belonging to a class. This makes a nice place where to
store the class information, as for K instance of an object you save
(K-1)*sizeof(class_id) bytes.
There might be other more Java specific reasons, but this should be
convincing enough.

More information about the kaffe mailing list