On Jun 8, 2015, at 1:45 PM, Rezaei, Mohammad A. <mohammad.rez...@gs.com> wrote: > > If that's the case, the documentation needs to be more clear :-) It currently > says: > > "Clears this reference object. Invoking this method will not cause this > object to be enqueued." > > I interpret that as meaning the reference will not be put on the queue as a > part of the clear() call. > > The bit of code that prevents this queuing is nowhere to be seen
It’s in the VM; see callers of (C++) discover_reference, which all skip that call if the referent is null. For example: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/annotate/431b1333b1c1/src/share/vm/oops/instanceRefKlass.inline.hpp circa line 47