I don\'t understand very well when an exception is ignored by the GC when it reclaims from the memory an object.
If I have a try/catch
into a finalize metho
It means that any exception thrown from the finalize
method is ignored. However, exceptions inside it still work as usual.
the finalize
method is run by the finalizer thread. if you throw exception, the finalizer will ignore it (swallow it). Otherwise, the finalizer thread would die.
This applies to exceptions that are thrown and not caught by your code (inside finalize()
). If you catch the exception, it is business as usual.
The two existing answers appear to say that the finalizer will ignore any uncaught exceptions. This appears to contradict the answer here: Exception in finalize method which appears to have a correct reference to the JSL. It says that uncaught exceptions will abort the finalization of the object concerned (possibly leaking resources) but that the finalizer thread itself will continue finalizing other objects. This matches empirical results.