method finalize and exceptions

后端 未结 3 697
梦谈多话
梦谈多话 2021-01-22 09:56

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

3条回答
  •  悲哀的现实
    2021-01-22 10:32

    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.

提交回复
热议问题