Mess with obsolete classes???

Andreas Raab Andreas.Raab at gmx.de
Fri Feb 15 00:28:46 UTC 2002


Nathanael,

> When I add a new instance variable to class and accept it, all the
> subclasses of class are being recreated with the new format. 
> At one point, 'Class class' is reshaped. This means that all the
> instances of this class have to be transformed (happens in the method 
> ClassBuilder>>update:to:).
> Since 'Class' is the sole instance of 'Class class', this 
> code tries to transform this instance, but it fails because 'Class'
> is referenced by other methods in the current runtime stack 
>('Class' is the class that actually gets a new instance variable
> and this happens *after* all its subclasses are reshaped!).
> This results in an error (self error: 'Illegal pointers to
> obsolete instances found') which stops the whole updating process.

I see the error as well, but your analysis is entirely wrong ;-)
It turns out that the error gets reported due to a metaclass having two
instances. Since #allInstances is implemente in Metaclass as "^Array
with: thisClass" only one of them is reported back. That leads to having
"left-over" old instances which means that something is _really_ and I
mean REALLY broken. The error messages you are seeing could also be
written as "this must never EVER happen" ;-) 

BTW, the second metaclass instance is created in the ClassBuilder
itself. I tried to replace this creation (as well as one other problem)
in a way that creates a metaclass as well and that works quite nicely -
up to the point where I was trying to add an instance variable to
Behavior, at which point my system died horribly. So there's still
something wrong when it gets to recompiling each and everything (the
magic here is that you recompile Metaclass as well as Metaclass class
and that's an instance of Metaclass which you are just recompiling ...
try to think _that_ through ;-) I had it working in the past though and
I know it can be done if you just walk the metaclass hierarchy twice.

> I'm pretty convinced that it is not possible to add a new 
> instance variable to Class in the normal way (changing the
> class definition and hit accept).

If you use the attached changes it works just fine. Now I only need to
figure out what's going wrong from Behavior.

Cheers,
  - Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FixClsBldr.2.cs
Type: application/octet-stream
Size: 4512 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020215/aff75667/FixClsBldr.2.obj


More information about the Squeak-dev mailing list