The ReferenceQueue class has a private long queueLength field. It is incremented by enqueue, and decremented by reallyPoll.
The *only* use of this field is in the hotspot agent code, in sun/jvm/hotspot/tools/FinalizerInfo.java. It obtains access using reflection. It is used to print the "current" number of objects pending finalization. Of course, that number can (and probably will) change almost immediately.
That count is also available via jdk.internal.misc.VM::geFinalRefCount(), and the agent could get it from there instead.
The *only* use of this field is in the hotspot agent code, in sun/jvm/hotspot/tools/FinalizerInfo.java. It obtains access using reflection. It is used to print the "current" number of objects pending finalization. Of course, that number can (and probably will) change almost immediately.
That count is also available via jdk.internal.misc.VM::geFinalRefCount(), and the agent could get it from there instead.
- relates to
-
JDK-8305327 (ref) ReferenceQueue should not count FinalReferences
-
- New
-