Saturday, July 10, 2010

finalize on object

I always wondered why there is a restriction saying that 'finalize' can be invoked only once on an object. To clarify, on a dead object, it must be invoked only once : but what if the object gets resurrected (for whatever reason) in the finalize and become 'live' again ? (ref here [1] for more)

Yes, it is bad practise, that is not what I am getting at though.
Speaking of which, I assume the 'state' of the object is unstable when it is resurrected ? Wonder how it works in context of final variables ! (think of circular dependencies of instance variables of two classes).
Weird that I never encountered or investigated these before ...


Any thoughts ? Comments ?


[1] If you want to read about object resurrection, check this old old article by Bill Venners under the "Avoid finalizer abuse" section : actually, read rest of article too, it is very informative !

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home