Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding java API finalize()

 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic