<br><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 11:12 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>Here it is.<br>
Just be aware, that its not intercepting all messages.<br>
Some messages like #== or #class is early bound by compiler/VM,<br>
so even if you redefine them, their behavior won't be changed.<br>
<br></blockquote><div><br>Thanks Igor. I am trying to understand your code.<br>Now...how I should use MessageCatchingProxy ?<br><br>how can I adapt this code to use your proxy?<br><br>| o p |<br>o := MyClass new.<br>o foo: 123.<br>
p := ClassProxy3 new.<br>p become: MyClass.<br>MyClass flushCache.<br>ClassProxy3 flushCache.<br>o == nil.<br>Transcript show: o class name; cr.<br>o foo.<br><br><br>thanks a lot<br><br>mariano<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
(I forgot where to get the list of these exceptional selectors).<br>
Smalltalk specialSelectors seems like not the same thing.<br></blockquote><div><br><br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
On 28 September 2010 23:48, Bert Freudenberg <<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>> wrote:<br>
><br>
><br>
> On 28.09.2010, at 22:29, Mariano Martinez Peck wrote:<br>
><br>
> Hi folks. I am trying to do something and I found a VM crash. Suppose I want to swap out a class, do a become with a proxy (that with the DNU will load the class back). In addition, I have instances of the swapped class.<br>
><br>
> Example of code (will crash in the last line):<br>
><br>
> o := MyObject new.<br>
> o foo: 123.<br>
> p := ClassProxy new.<br>
> p become: MyObject.<br>
> o == nil.<br>
> o foo.<br>
><br>
><br>
> My Object just extends Object, has an instVar 'foo', and implements the accessors.<br>
><br>
> ClassProxy implements:<br>
><br>
> become: aClass<br>
> className := aClass name.<br>
> aClass fileOut.<br>
> super become: aClass<br>
><br>
> and<br>
><br>
> doesNotUnderstand: aMessage<br>
> | reloadedClass |<br>
> (FileStream fileNamed: className, '.st') fileIn.<br>
> reloadedClass := Smalltalk at: className.<br>
> self becomeForward: reloadedClass.<br>
> ^aMessage sendTo: reloadedClass<br>
><br>
><br>
> So....does someone know why the crash?<br>
><br>
> Looks like o's class pointer does not point to a class after the become. When the VM tries to lookup #foo in o's class it crashes.<br>
><br>
> how can I solve it ?<br>
><br>
> I'd say you cannot get rid of a class if there are still instances of it. You can stub out the class however. If the method dict is nil, the VM will send cannotInterpret: if you send a message to an instance. You should be able to use that instead of #doesNotUnderstand:.<br>
> - Bert -<br>
><br>
><br>
><br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br></blockquote></div><br>