Check out the new USENIX Web site. next up previous
Next: Correctness Up: Idea Previous: Class loader

Example

Consider what happens at run time when executing a virtual method invocation o.m, where o is of static class C. Suppose this method invocation appears in the body of class B. The statically determined ctable of class B designates an offset $ k$ for the method m of class C. In our scheme, o.m is compiled to access the entry $ k$ of class B's offset table for a new offset $ k'$. This new offset $ k'$ is copied from the global allocation table during class loading. It is the actual offset of the method m in the vtable of class C. Although the dynamic class of object o could be a subclass of C, it is safe to use the offset $ k'$ to access the vtable of object o for invoking the method, because we have arranged the vtables of a superclass and its subclasses to be consistent.



Dachuan Yu 2002-05-23