'finalize()' 方法是否总是在销毁 'Unreachable' 对象之前由垃圾收集器调用?

Is 'finalize()' method always called by garbage collector before destroying an 'Unreachable' object?

我从以下红link:garbage collection from geeksforgeeks 这里据说:

The finalize() method is never invoked more than once for any given object.

所以,这里说 "more than once" 我想知道是否有可能 finalize() 方法未被调用,垃圾收集器会销毁该对象。

可能吗?

当 GC 发现 class 的对象(其中 finalize() 已被覆盖)时,会将其添加到对象队列中以调用 finalize()。只有在对象完成一次之后,GC 才能清理它。即这将在以后的 GC 上。

例如如果一个对象处于 tenured space,它可能会在执行完整收集之前被发现,并且只有在调用 finalize 方法后才会在完整 GC 上清理。

有关详细信息,这是 Java 11 Javadoc for Object.finalize()

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#finalize()

so is there any possibility that garbage collector fully destroyed the object in heap but didn't call the finalize() method on that object?

当对象在完成队列中时,无法将其删除。

And you all assumed that there is not certainity in the destroying of object by the garbage collector.

它不会在仍然有强引用时被销毁。