[squeak-dev] [Bug][Fix] In ReferenceStream, code review request

Juan Vuletich juan at jvuletich.org
Thu Dec 1 09:19:36 UTC 2011


Mariano Martinez Peck wrote:
>
> ...
>
>     But a serialized model should be materializable in, for instance,
>     an UI-less server, or some client with a very different UI
>     framework, etc. This would enable (among many other useful things)
>     sharing serialized objects between Cuis, Squeak and Pharo.
>
>
> I understand what you mean but I think this concrete example is wrong. 
> Since the model doesn't know the view (hence the view is not 
> serialized), wouldn't it always be able to be materialized in a 
> UI-less server?

The view is weakly referenced. That's the whole point.

The bug is that the view class is included in the serialized stream, and 
is required to exist on materialization. Hence, the fix.

Cheers,
Juan Vuletich

Ps. I copied the test again below. Please take a look at it (that's what 
it is for).

> Thanks!
>
>
>
>
>            !ReferenceStreamTest methodsFor: 'testing' stamp: 'jmv
>         11/27/2011
>            14:56'!
>            testWeakDumps
>                   "Test that if we serialize a model with weak
>         references to
>            views, only the model is serialized and not the views.
>
>                   Note: The bug became apparent only when dumping a
>         model to
>            a SmartRefStream, that calls #references, and the
>         serialized stream
>                   was later materialized in an image where the view
>         classes
>            had been deleted. In such rare cases, materialization would
>         fail
>            when trying to reference these
>                   absent classes. If serializing to a ReferenceStream, the
>            bug didn't become apparent (views were never serialized). If
>            serializing to a SmartRefStream, but
>                   view classes still existed, the bug didn't really become
>            apparent (because views were not actually deserialized),
>         the only
>            effect was a larger file.
>
>                   ReferenceStreamTest new testWeakDumps
>                   "
>                   | oldInstance refStream |
>                   oldInstance :=StringHolder new contents: 'This is a
>         text'.
>                   oldInstance addDependent: Morph new.
>                   refStream := ReferenceStream on: (DummyStream on: nil).
>                   refStream nextPut: oldInstance.
>                   self deny: (refStream references keys anySatisfy: [
>            :dumpedObject | dumpedObject isKindOf: Morph ])! !
>
>
>
>
>
> -- 
> Mariano
> http://marianopeck.wordpress.com
>




More information about the Squeak-dev mailing list