> On Dec 5, 2015, at 3:12 AM, Peter Levart <[email protected]> wrote:
>
>
>
> On 12/04/2015 10:58 PM, Mandy Chung wrote:
>> "It is possible to create a phantom reference with a null queue, but such a
>> reference is completely useless: Its get method will always return null and,
>> since it does not have a queue, it will never be enqueued.”
>>
>> The puzzling part to me is why PhantomReference accepts null ReferenceQueue.
>> I can’t evaluate how high of the source incompatibility risk if we fixed
>> it but I may propose that in a future release until I have cycle.
>>
>> Mandy
>>
>
> Well, it is not completely useless for PhantomReference to accept null
> ReferenceQueue. It's sometimes useful to have a common subtype of
> PhantomReference where most of instances perform a function of
> PhantomReference, but some instances are just there to provide the "glue" in
> the data structure. See the implementation of java.lang.ref.Cleaner and it's
> "root" nodes of a doubly-linked list ;-)
That’s right.
There may likely be some reason why it takes the null ReferenceQueue as noted
in this comment in sun.misc.Cleaner:
// Dummy reference queue, needed because the PhantomReference constructor
// insists that we pass a queue.
Mandy