aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question regarding java API finalize() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question regarding java API finalize()" Watch "Question regarding java API finalize()" New topic
Author

Question regarding java API finalize()

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Directly from this API:

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized.


I have not got this point : except as a result of an action taken by the finalization of some other object or class which is ready to be finalized

What would this exception be? Could you make a real life code example?

UPDATE:

even this following bit of the same method description is not very clear:

For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.


last but not least:

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.


Does it halt the process or ignore the exception?


to break the connection? the connection should be closed with close()..

Thanks in advance.



OCAJP 7, OCPJP 7
 
wood burning stoves
 
subject: Question regarding java API finalize()