Problem with Proxies, objects and MethoDict

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Proxies, objects and MethoDict

Mariano Martinez Peck
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.

Example of code (will crash in the last line):

o := MyObject new.
o foo: 123.
p := ClassProxy new.
p become: MyObject.
o == nil.
o foo.


My Object just extends Object, has an instVar 'foo',  and implements the accessors.

ClassProxy implements:

become: aClass
    className := aClass name.
    aClass fileOut.
    super become: aClass

and

doesNotUnderstand: aMessage
    | reloadedClass |
    (FileStream fileNamed: className, '.st') fileIn.
    reloadedClass := Smalltalk at: className.
    self becomeForward: reloadedClass.
    ^aMessage sendTo: reloadedClass


So....does someone know why the crash?

how can I solve it ?

Thanks in advance

Mariano

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Proxies, objects and MethoDict

Stéphane Ducasse
Mariano

why your proxy class does not have at least a format, methodDict and superclass?
In the past

        Behavior new something was carashing the vm because methodDict was nil and boum it crashed.
        I fixed that long time ago.
        Now I think that a class proxy cannot be just the same as an object proxy from the vm look at structure.

Stef

On Sep 28, 2010, at 10:29 PM, Mariano Martinez Peck wrote:

> 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.
>
> Example of code (will crash in the last line):
>
> o := MyObject new.
> o foo: 123.
> p := ClassProxy new.
> p become: MyObject.
> o == nil.
> o foo.
>
>
> My Object just extends Object, has an instVar 'foo',  and implements the accessors.
>
> ClassProxy implements:
>
> become: aClass
>     className := aClass name.
>     aClass fileOut.
>     super become: aClass
>
> and
>
> doesNotUnderstand: aMessage
>     | reloadedClass |
>     (FileStream fileNamed: className, '.st') fileIn.
>     reloadedClass := Smalltalk at: className.
>     self becomeForward: reloadedClass.
>     ^aMessage sendTo: reloadedClass
>
>
> So....does someone know why the crash?
>
> how can I solve it ?
>
> Thanks in advance
>
> Mariano
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project