harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Deakin <oliver.dea...@googlemail.com>
Subject [drlvm] Should the referent of a PhantomReference be cleared before it is enqueued?
Date Wed, 11 Aug 2010 17:17:17 GMT
  I have discovered that DRLVM appears to clear the referent field of a 
PhantomReference before calling its enqueue() method (this can be shown 
quite easily by printing the referent field in Reference.enqueue()). 
This behaviour appears to differ from the RI, on which a non-null 
referent can be got hold of via reflection [1]. The spec for 
PhantomReference says:

"Unlike soft and weak references, phantom references are not 
automatically cleared by the garbage collector as they are enqueued. An 
object that is reachable via phantom references will remain so until all 
such references are cleared or themselves become unreachable."

This reads to me that soft and weak references clear their referent 
field before being enqueued, but phantom references should only make the 
referent eligible for gc once the referent is no longer phantomly 
reachable (or reachable at all). If this is the case, it would seem that 
DRLVM's current behaviour does not match the spec.

Any comments/thoughts?

Regards,
Oliver

[1] An example of this kind of use/abuse of PhantomReference can be 
found at:
http://www.roseindia.net/javatutorials/references.shtml

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Mime
View raw message