[9] RFR (XS): 8169000: Define reference reachability more precisely in java.lang.ref package
David Holmes
david.holmes at oracle.com
Mon Nov 14 22:52:59 UTC 2016
Hi Zoltan,
On 15/11/2016 12:28 AM, Zoltán Majó wrote:
> 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/
I don't think you need the "(i.e ...)". You are cross referencing to the
Reachability section where "strongly reachable" is defined.
The fewer the changes the better - the key part is to make it clearer
that it "may" never be enqueued, without getting bogged down with why,
or why not.
Of course this will need to go through CCC.
Thanks,
David
> 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