[squeak-dev] The Trunk: Environments-cmm.53.mcz

Chris Muller asqueaker at gmail.com
Mon Jan 19 00:17:28 UTC 2015


I'm moving this to trunk now because I've just noticed a painful
side-effect of this bug [1].  After renaming a class, the ClassBindings in
the methods of the renamed class will be corrupted.  Know that if you try
to save the package with the renamed class, Monticello will \silently
exclude/ methods of the renamed class (because MC will only save methods
with #isLocalSelector).

I didn't realize that until I found myself in my newly-built image with
several methods missing from my MC package.  Thankfully I still had the old
image to develop and run this script [2] to identify and replace the
incorrect ClassBindings in the CM's of the Class which was renamed.

If anyone else has used rename on the class menu, I hope this script will
help you fix your image.  If you had already saved a package after a class
rename, be sure to select "check all packages for changes" from the MC
working copy menu after running the script.

 - Chris

[1] -- We have two bugs.  "this bug" refers to the one fixed here in
#renameClass:from:to:.  The other one is the invalid super pointer and
still unfixed.  That problem is easy to reproduce by that script in my
original email ("invalid super pointer"), and we really could use a
CM-structure / Bytecode expert to take a look, as it is also a pretty nasty
bug.  Thanks!

[2]

     | notAtHome |
     notAtHome := Array streamContents:
          [ : stream |
          Smalltalk allClasses do:
               [ : eachClass |
               eachClass methodDictionary valuesDo:
                    [ : eachCm | eachCm methodHome = eachClass ifFalse: [
stream nextPut: eachCm -> eachClass ]]] ].
     notAtHome ifNotEmpty: [ Warning signal: 'The following methods were
found to have a methodHome that was not their containing Class.  They will
be rehomed.

     ', (notAtHome) ].
     notAtHome do:
          [ : eachCmAndCorrectHome |
          eachCmAndCorrectHome key
               literalAt: eachCmAndCorrectHome key numLiterals
               put: (Smalltalk environment bindingOf: eachCmAndCorrectHome
value name) ]



On Sun, Jan 18, 2015 at 5:44 PM, <commits at source.squeak.org> wrote:

> Chris Muller uploaded a new version of Environments to project The Trunk:
> http://source.squeak.org/trunk/Environments-cmm.53.mcz
>
> ==================== Summary ====================
>
> Name: Environments-cmm.53
> Author: cmm
> Time: 16 January 2015, 2:54:24.767 pm
> UUID: 69b32fc7-98f1-4c19-9976-a38106a9ee63
> Ancestors: Environments-cmm.52
>
> - Only change key when it is NOT in the 'bindings' Dictionary, otherwise
> it would be in a state inconsistent with its new hash.
>
> =============== Diff against Environments-cmm.51 ===============
>
> Item was changed:
>   ----- Method: Environment>>renameClass:from:to: (in category 'classes
> and traits') -----
>   renameClass: aClass from: oldName to: newName
>         "Rename the class, aClass, to have the title newName."
>
>         | binding category |
>         category := self organization categoryOfElement: oldName.
>         self organization classify: newName under: category
> suppressIfDefault: true.
>         self organization removeElement: oldName.
>
> +       binding := self associationAt: oldName.
> -       binding := self declarationOf: oldName.
>         declarations removeKey: oldName.
> +       bindings removeKey: oldName.
> + "     self binding: binding removedFrom: self."
> -       self binding: binding removedFrom: self.
>
> +       binding key: newName.
> +       declarations add: binding.
> +       bindings add: binding.
> + "     self binding: binding addedTo: self."
> -       binding := newName => aClass.
> -       declarations add: binding.
> -       self binding: binding addedTo: self.
>
>         Smalltalk renamedClass: aClass from: oldName to: newName.
>         SystemChangeNotifier uniqueInstance
>                 classRenamed: aClass
>                 from: oldName
>                 to: newName
>                 inCategory: category!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150118/0694a0b5/attachment.htm


More information about the Squeak-dev mailing list