Robert Klemme
10/29/2004 10:34:00 AM
"leon breedt" <bitserf@gmail.com> schrieb im Newsbeitrag
news:270bd0c40410290325747ed75f@mail.gmail.com...
> hi,
>
> i'm curious as to why finalizers receive object id only, and cannot
> have access to the instance being destroyed. i'm sure there's a good
> reason behind this bit of documentation:
>
> "May not becalled on an object id passed as a parameter to a finalizer."
>
> is it because of locks, or the possibility of the object being
> re-referenced by something the programmer can do in the finalizer?
I guess the latter. I mean, the GC decided that the instance can be
thrown away when the finalizer is invoked, so there's no point in making
it live again. Allowing finalizers to lock instances it in mem after
their death, would make the GC far more complex. Making the object
accessible leads to all kinds of strange logic. For example in Java,
finalize() is called at most once even if the object reference is
resurrected. *shudder*
Kind regards
robert