[9] RFR (XS): 8169000: Define reference reachability more precisely in java.lang.ref package (original) (raw)

Zoltán Majó zoltan.majo at oracle.com
Tue Nov 15 12:04:41 UTC 2016


Hi Peter,

On 11/14/2016 10:59 PM, Peter Levart wrote:

Hi Zoltan,

On 11/14/2016 03:28 PM, Zoltán Majó wrote: [...]

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? Yes, I think this is good. Maybe just a nit. This last statement: "It is the responsibility of the program using reference objects to ensure that the objects remain strongly reachable for as long as the program is interested in their referents." ...could be written more nicely like: "It is the responsibility of the program to ensure that reference objects remain strongly reachable for as long as it is interested in their referents." ...or even: "It is the responsibility of the program to ensure that reference objects remain strongly reachable for as long as it is interested in tracking the reachability of their referents." What do you think?

yes, it sounds better, but probably it's best if we keep this change to a minimum. So I'd add only the word "strongly" to that sentence.

Please see the updated webrev in my reply to Mandy.

Thank you!

Best regards,

Zoltan

Regards, Peter

Thank you! Best regards,

Zoltan

The following modified test shows this situation:

public class WeaklyReachablePhantomReference { static ReferenceQueue rq = new ReferenceQueue<>(); static WeakReference<PhantomReference> 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