[Glass] Grrrr cannot migrate (class rename with subclasses and with a name of a deleted class)

Martin McClure via Glass glass at lists.gemtalksystems.com
Wed Aug 26 16:51:19 PDT 2015


On 08/26/2015 04:39 PM, Mariano Martinez Peck wrote:
> I am very very glad I asked. Thank you very much guys. Cannot believe so
> simply it actually was. 
> So..to my defense, I didn't know a class rename was possible without
> going with the migration code :)

This simplicity is not really very obvious.

And it's not *quite* as simple as we indicated. You should also check
for code references to the class name, and edit those methods as needed.
If a method references "FaSecurityClosingPriceRecord2" it's going to
fail the next time you need to recompile it after changing the name of
the class, and if it references "FaSecurityClosingPriceRecord" and was
compiled before you made the change it still references the class you
deleted.


The reason that a class rename is relatively simple is that a class
doesn't use its name for anything important at runtime. The only reason
that I know of for a class to know its own name is so it can put in a
print string for debugging.

At compile time, the compiler finds a class by looking up its name in
the symbol dictionaries, so in order to compile references to a class
you need the dictionary entry. Class names don't really do much more
than that -- the instances don't usually care.


Of course if you change instance variables, or the superclass hierarchy,
then the instances are usually affected and you still must do a migration.

Regards,

-Martin


More information about the Glass mailing list