摘要 |
A method, system and computer program product for converting a class (i.e., type) of an object from a first class to a second class. Multiple classes, class layouts, and an object layout are received. A first class layout references a first virtual function table (v-table) that defines behaviors of the first class. A second class layout references a second v-table that defines behaviors of the second class. The object layout includes a reference to the first v-table to define runtime behaviors of the object as the behaviors of the first class. At runtime, the reference in the object layout is modified to reference the second v-table to update the object's runtime behaviors to the behaviors of the second class, thereby converting the object from the first class to the second class without changing to an object layout memory address or to any class layout.
|