Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if an exception is thrown during finalize()

What would happen if an exception is thrown during the execution of finalize()? Is the stack unwind like normally? Does it continue finalize() and ignore the exception? Does it stop finalize() and continue GC the object? Or something else?

I'm not looking for guidelines of using finalize() there are plently of pages explaining that.

like image 221
Peter Ølsted Avatar asked Jun 14 '10 14:06

Peter Ølsted


1 Answers

From the Object#finalize() javadoc:

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

like image 67
Gnoupi Avatar answered Sep 30 '22 21:09

Gnoupi