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

Mandy Chung mandy.chung at oracle.com
Tue Nov 15 01:51:11 UTC 2016


> On Nov 14, 2016, at 6:28 AM, Zoltán Majó <zoltan.majo at oracle.com> wrote:
> 
> Here is the updated webrev with the updated text:
> 
> http://cr.openjdk.java.net/~zmajo/8169000/webrev.01/
> 

This spec uses “unreachable” to refer to when GC detects as unreachable. I think the current spec is correct. 

What about this suggested clarification?  

diff --git a/src/java.base/share/classes/java/lang/ref/package-info.java b/src/java.base/share/classes/java/lang/ref/package-info.java
--- a/src/java.base/share/classes/java/lang/ref/package-info.java
+++ b/src/java.base/share/classes/java/lang/ref/package-info.java
@@ -77,8 +77,12 @@
  * references that are registered with it.  If a registered reference
  * becomes unreachable itself, then it will never be enqueued.  It is
  * the responsibility of the program using reference objects to ensure
- * that the objects remain reachable for as long as the program is
- * interested in their referents.
+ * that the objects remain strongly reachable for as long as the program
+ * is interested in their referents.
+ *
+ * <p>
+ * A Java virtual machine may implement optimization that could
+ * affects when objects become unreachable.
  *
  * <p> While some programs will choose to dedicate a thread to
  * removing reference objects from one or more queues and processing


Peter, 

> On Nov 14, 2016, at 1:59 PM, Peter Levart <peter.levart at gmail.com> wrote:

> 
> "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."
> 


Making it clear “strongly reachable” is a good suggestion.  I don’t see word-smithing is needed in the original sentence; hence my above suggested change only adds the word “strongly” in this sentence.

Mandy


More information about the core-libs-dev mailing list