Possible explanation for oddity with deleted class

Ross Boylan RossBoylan at stanfordalumni.org
Sat Sep 10 01:13:05 UTC 2005


At http://minnow.cc.gatech.edu/squeak/2176, Herbert König writes
-----------------------------------------------------
After refactoring I inadvertedly deleted a class and filed it in again
from a previous fileout.  After that a method like

  myMethod
     | tempVar |
      tempVar := DeletedAndRestoredClass new.
      tempVar validMessageToTempVar.


created an exception "AnObsoleteDeletedAndRestoredClass does not
understand validMessageToTempVar".

Tried in vain everything presented here and every hint Dan Ingalls
kindly provided.

Two solutions
1- filed out every category I wrote and filed it in in a fresh image.
2- Changed the metod to:

  myMethod
     | tempVar |
      tempVar := nil.
      tempVar := DeletedAndRestoredClass new.
      tempVar validMessageToTempVar.


sent the method once, deleted the change.
--------------------------------------------------------

I have a theory of what happened, based mostly on the code in the one
of the DateAndTime changesets.  That code swaps the names of classes
and then recompiles all methods referring to the classes.

I infer that the references to classes in compiled methods point to
the class object at the time the method was compiled.  I also notice
that most of pointer tools don't pick up references to a class from
compiled methods.  I'm not sure if this is because the tools
deliberately drop such references (some code suggests that), or
because the references are somehow not the usual object references.

So here's the theory: when the class was deleted, the compiled methods
continued to refer to it.  I also think (from looking at some of the
code for deleting classes) that the class object may have stuck around
in some ghostly form (e.g., with all its methods and instance vars
removed).

So when you filed in the "new" class it became a new object.  The
compiled methods continued to reference the old one.  So when they
ran, you got an error.  Both solutions cause recompilation of the
method in the presence of the new class.

In this interpretation, the significance of setting tempVar := nil has
nothing to do with the semantics; the significance is rather that it
forced recompilation of the method, thereby picking up the reference
to the new instance of DeletedAndRestoredClass and causing the
compiled method to work again.

Comments?
Ross Boylan



More information about the Squeak-dev mailing list