> IIRC all objects technicaly have finalizer.  The question is which
> objects have non-trivial finalizers.  If (to allow changing class
> hierarchies as above) you require all classes to contain:
> 
>    public void finalize () { super.finalize(); }

The JLS spec calls that a trivial finalizer ...

> (which is a logical extension of what you said), 

It is NOT a logical extension of what I'm saying. I'm saying that
non-trivial finalizers should always include a call to super.finalize().
It does NOT follow that every class should have a finalizer.  

Adding a trivial finalizer does NOT help in the event that the
programmer changes the classes position in the class hierarchy.
But having a (previously redundant) super.finalize() call in a
non-trivial finalize method may turn out to be a GOOD THING.

> I'm not sure what "setting up the stacks etcetera" refers to.
> However, objects with (non-trivial) finalizers are quite expensive
> in many Java implementations.

Yes ... but 90% of the cost is incurred before the most-derived
finalizer is called, or after it returns.  And even when the finalizer
is called, the cost of executing the instance's finalization code will
be far greater than the cost of a call to java.lang.Object.finalize
... which is going to return in a JVM instruction or two.

-- Steve



_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to