<br><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 11:12 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</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&#39;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 &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On 28.09.2010, at 22:29, Mariano Martinez Peck wrote:<br>
&gt;<br>
&gt; 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>

&gt;<br>
&gt; Example of code (will crash in the last line):<br>
&gt;<br>
&gt; o := MyObject new.<br>
&gt; o foo: 123.<br>
&gt; p := ClassProxy new.<br>
&gt; p become: MyObject.<br>
&gt; o == nil.<br>
&gt; o foo.<br>
&gt;<br>
&gt;<br>
&gt; My Object just extends Object, has an instVar &#39;foo&#39;,  and implements the accessors.<br>
&gt;<br>
&gt; ClassProxy implements:<br>
&gt;<br>
&gt; become: aClass<br>
&gt;     className := aClass name.<br>
&gt;     aClass fileOut.<br>
&gt;     super become: aClass<br>
&gt;<br>
&gt; and<br>
&gt;<br>
&gt; doesNotUnderstand: aMessage<br>
&gt;     | reloadedClass |<br>
&gt;     (FileStream fileNamed: className, &#39;.st&#39;) fileIn.<br>
&gt;     reloadedClass := Smalltalk at: className.<br>
&gt;     self becomeForward: reloadedClass.<br>
&gt;     ^aMessage sendTo: reloadedClass<br>
&gt;<br>
&gt;<br>
&gt; So....does someone know why the crash?<br>
&gt;<br>
&gt; Looks like o&#39;s class pointer does not point to a class after the become. When the VM tries to lookup #foo in o&#39;s class it crashes.<br>
&gt;<br>
&gt; how can I solve it ?<br>
&gt;<br>
&gt; I&#39;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>

&gt; - Bert -<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br></blockquote></div><br>