[9] RFR (XS): 8169000: Define reference reachability more precisely in java.lang.ref package
Zoltán Majó
zoltan.majo at oracle.com
Mon Nov 14 14:28:46 UTC 2016
Hi Peter,
On 11/11/2016 04:33 PM, Peter Levart wrote:
> [...]
> I think the wording could be even less specific about "detecting" the
> reachability of the reference object. For example:
>
> ... If a registered reference becomes unreachable itself, then it
> *may* never be enqueued.
>
>
> In addition, the situations that describe when the reference *may* not
> be enqueued could be expanded. For example:
>
> ... If a registered reference ceases to be strongly reachable itself,
> then it *may* never be enqueued.
>
thank you for the suggestion and for the example program!
Here is the updated webrev with the updated text:
http://cr.openjdk.java.net/~zmajo/8169000/webrev.01/
Does that look reasonable to you?
Thank you!
Best regards,
Zoltan
>
> The following modified test shows this situation:
>
>
> public class WeaklyReachablePhantomReference {
>
> static ReferenceQueue<Object> rq = new ReferenceQueue<>();
> static WeakReference<PhantomReference<Object>> weakRefRef;
>
> public static void main(final String[] args) throws Exception {
> weakRefRef = new WeakReference<>(
> new PhantomReference<>(
> new Object(),
> rq
> )
> );
> // <- here
> System.gc();
> Reference rmRef = rq.remove(1000);
> if (rmRef == null) {
> System.out.println("PhantomReference NOT enqueued");
> } else {
> System.out.println("PhantomReference enqueued");
> }
> }
> }
>
>
> At "<-- here" the PhantomReference object becomes weakly reachable
> while its referent becomes phantom reachable and this is enough for
> PhantomReference to not be enqueued.
>
>
> Regards, Peter
>
More information about the core-libs-dev
mailing list