Before I recognized that Adrian fixed the

ObjectFinalizerTests>>testFinalizationOfEquals

I gave it try myself. I came to the same conclusion as Adrian 
how to fix. But now after knowing how it works I do not know 
why the test succeeds :)

The test uses

1 to: 5 do: [:n | o := Object new. bag add: n. o toFinalizeSend:
#remove: to: bag with: n].
1 to: 5 do: [:n | o := Object new. bag add: n. o toFinalizeSend:
#remove: to: bag with: n].

My problem is that toFinalizeSend:to:with adds an Objectfinalizer 
to the finalizationRegistry of the instance. But

Object>>finalizationRegistry
   "Answer the finalization registry associated with the receiver."
   ^WeakRegistry default

returns a global object which is WeakKeyDictionary. And

| d |
d := WeakKeyDictionary new.
d at: (1 asString copy) put: $a.
d at: (1 asString copy) put: $b.
d size

prints 1. To me that would exchange every entry from the first
run by the second run (because the objects are equal). 

So I would assume that if there does not happen a run of the
garbagecollector between the two loops the objects of the first
loop should be still contained in the bag. But the test is named
finalizationOfEquals so I have to assume: self doesNotUnderstand

Can someone explain it to me, please?

Norbert


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

Reply via email to