RFR: 8071507: (ref) Clear phantom reference as soft and weak references do

Peter Levart peter.levart at gmail.com
Sat Dec 5 11:12:20 UTC 2015



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 ;-)

Regards, Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20151205/5448c5b6/attachment.htm>


More information about the hotspot-gc-dev mailing list