[3052] in java-interest

home help back first fref pref prev next nref lref last post

Finalize()

daemon@ATHENA.MIT.EDU (Richard Williamson)
Fri Oct 27 19:36:55 1995

From: Richard Williamson <richwill@infoscape.com>
Date: Fri, 27 Oct 95 15:04:50 -0700
To: java-interest@java.sun.com

This comment in the Java documentation was pointed out to me:

>When a user defines the void finalize() method in a class  
>definition, finalization is enabled for objects of that class.  
>Finalization of an object consists of the system calling the  
>object's finalize() method. Finalization normally occurs  
>asynchronously at some time after the garbage collection mechanism  
>identifies an object as inaccessible. Users can invoke their  
>finalize() method explicitly but this doesn't guarantee that the  
>system will not call it again at a later time. If a finalized  
object >references another finalized object, the objects are  
finalized in *>the reverse order of their creation. Java does not  
guarantee
*>when or if a given finalized object will have its finalize()  
method *>called. Thus, finalization should not be relied on for  
program *>correctness. Rather, finalization should be thought of as  
an *>optimization.

The final few sentences is this footnote are somewhat alarming.   
How can finalize() be used for ANYTHING if it isn't reliably called?

- Richard Williamson
richwill@infoscape.com
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post