The java.lang.ref.Cleaner maintains Cleaner.Cleanable, a subclass of PhantomReference referring to an object and the corresponding cleaning function.
The Cleanable instances are visible to and retained by clients of the Cleaner.
It should be possible to observe the existence of the Cleanable to know whether the cleaning function has yet to be performed.
A race condition may exist in the processing of the Cleanable when it is removed from the ReferenceQueue that might indicate the cleaning function has been completed, while it is still in progress.
The race is between the garbage collector and the CleanerImpl.
After the reference to the Cleanable is removed from the ReferenceQueue, the cleaning function is invoked. The garbage collector may determine that the Cleanable itself is no longer referenced (except perhaps by another Weak/Soft/ or PhantomReference) and reclaim it.
jdk.internal.ref.CleanerImpl:144 should be a call to ReachabilityFence(ref) to keep it alive until the call to the cleaning function returns.