[Fix] ClassBuilder (Obsolete Classes)

Nathanael Scharli n.schaerli at gmx.net
Tue Apr 23 09:01:11 UTC 2002


About one and a half month ago, I was trying to add some instance variables
to kernel classes such as ClassDescription in Squeak 3.2. Unfortunately,
this didn't work and the compilation process ended with an error
notification. Analyzing the situation more detailed, I found that the class
hierarchy in Squeak 3.2 is not consistent. This means that there are
obsolete subclasses that are not properly registered as obsolete subclasses
of their superclass. And, even worse, there are many obsolete subclasses
stored in the System Dictionary! (Not to forget that they are associated to
a key that is a String and not a Symbol, which does not really make sense in
an identity dictionary).

Unfortunately, the problem cannot be solved by just cleaning the class
hierarchy manually, because the ClassBuilder is broken and does create new
inconsistencies when classes are created, renamed or deleted. Since I really
needed to have a clean state, I took the time and debugged this issue.
Thereby, I found several places (in different methods) where the process of
building/reshaping classes was broken.

I fixed all of them and since then, my Squeak has been remaining in a
completely consistent state. (I have been using it like that for moe than a
month and I have done a lot of kernel changes).

As an attachment, you'll find a changeset with my bugfixes. In addition,
there are some methods, on the class side of ClassBuilder that clean up the
class hierarchy and check whether it is in a consistent state.

When you file in the changeset, the method

ClassBuilder class>>cleanupAndCheckClassHierarchy

gets executed automatically (as a postscript). You can always check the
whether your system is consistent by executing

ClassBuilder class>>checkClassHierarchyConsistency

This method checks whether there are no weird obsolete classes in the
SystemDictionary and whether the class hierarchy is consistent. Consistency
means that for all classes A and B it holds that:

- B is obsolete and 'B superclass' yields A  <-->  'A obsoleteSubclasses'
contains B
- B is not obsolete and 'B superclass' yields A  <-->  'A subclasses'
contains B"

I just applied the fix to a recent Squeak 3.2gamma image (4827). It worked
nicely and the image got about 80K smaller because many unnecessary obsolete
subclasses get garbage collected.

So, please check out my changes and incorporate them into the final version
of Squeak 3.2 if possible! (I spent a lot of time debugging this issue and
so I would really like it if others could benefit from that).


IMPORTANT: This bugfix cannot be applied to Squeak 3.3, because the module
stuff affects the way the ClassBuilder works. However, I'm going to talk
with Henrik next week (he is visiting our lab) and afterwards I'm going to
port my bugfix to Squeak 3.3.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ClassBuilderFix.1.cs
Type: application/octet-stream
Size: 15269 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020423/d22858df/ClassBuilderFix.1.obj

More information about the Squeak-dev mailing list