JEP 132: More-prompt finalization
    David Holmes 
    david.holmes at oracle.com
       
    Thu Jan  5 18:41:33 PST 2012
    
    
  
On 6/01/2012 3:37 AM, Kirk Pepperdine wrote:
> I get the feeling that what people are looking for is a destructor..
> and in Java the destructor is close(). One has to consider finalization
> of any resource to be the mechanism of last resort or when all else
> fails, finalization will catch it (assuming it has a chance to run). Eg,
> it's the application's responsibility to call close(). If you know
> enough to call System.gc() (or any other API), you should know enough to
> call close.
Not to defend finalization in any way but the key difference is that any 
part of the code can call System.gc() or System.runFinalization() 
without needing to know what exactly needs to be finalized. Afterall the 
key thing about GC is it relieves the programmer from having to manage 
object lifetimes, so if you don't know when the object is no longer used 
you don't know when to call close.
David
    
    
More information about the hotspot-dev
mailing list