next up previous
Next: Use Specialization Up: Object Inlining Transformation Previous: Cloning

Restructuring Classes

When adding inlined fields to a class, we must avoid altering the layout of other fields of the class. Consider a polymorphic container in which an inlined field has different types in different situations: it has been cloned, but we need not clone methods that do not use the inlined field if we can preserve the layout of the other fields across all the cloned classes. Furthermore, the layouts of the container class and any subclasses must remain conforming. Both constraints can be satisfied by replacing the inlined field with one field from the inlined class, and adding the rest of the fields at the end of the fields of the container class. This is illustrated in Figure 11

  
Figure 11: New Rectangle and Parallelogram



Julian Dolby
dolby@cs.uiuc.edu