Instances of Metaclass, such as
OrderedCollection class,
Process class,
Magnitude class, etc., and instances of instances of
Metaclass, such as
OrderedCollection,
Process,
Magnitude, etc., are considered as special objects because each of these objects is unique in the image. That is, there is exactly one instance of
Metaclass with the name
Dictionary (also known as
Dictionary class), and there is only one instance of
Dictionary class (also known as
Dictionary) in an image.
In order to unload instances of Metaclass and instances of instances of
Metaclass as non-special objects (that is, no replacement performed), the
ObjectDumper must be explicitly set to handle these instances as ordinary objects.
ObjectDumper instance method
classesTreatedAsObjects: will override its default setting and unload the specified classes as objects. The following example shows how you can unload the class
ObjectSwapper as an object.
You must be extremely careful when unloading classes as ordinary objects because classes usually contain references to instances of CompiledMethod. You must use
ObjectDumper instance method
overrideUndumpableClasses or unlink all instance variables that contain references to these instances of
CompiledMethod. In the example above, when the object (class
ObjectSwapper) is loaded back into an image that already contains the class
ObjectSwapper, the newly loaded object,
ObjectSwapper, will not be identical to the one already in the image. It is therefore possible for you to create an unstable image which contains more than one instance of
Metaclass with the same name. Typical user applications should not use this feature. Advanced applications such as the VA Smalltalk development environment use this feature to implement loading of classes and methods.
Copyright 2005, 2019 Instantiations, Inc. All rights reserved.