Any class that includes a finalize method should invoke its superclass' finalize method.
Correct me if Im wrong, but I think the answer is true. In contrast to constructors, finalize methods do not implicitly call their superclass' finalizers. Example: If the superclass uses the finalize method to close a database connection and the subclass doesnt do that in its own finalize, then the databse connection is never closed when using an object of the subclass. Hence, you should call the super finalize() inside finalize() of subclass.
The fact that class Object declares a finalize method means that the finalize method for any class can always invoke the finalize method for its superclass, which is usually good practice. (Unlike constructors, finalizers do not automatically invoke the finalizer for the superclass; such an invocation must be coded explicitly.)
posted 16 years ago
Thanks Richard and Karel
You don't like waffles? Well, do you like this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop