RFR: Small cleanups in java.lang.ref (original) (raw)

mark.reinhold at oracle.com mark.reinhold at oracle.com
Fri May 18 15:32:11 UTC 2018


2018/5/18 3:11:25 -0700, per.liden at oracle.com:

On 05/17/2018 10:03 PM, mark.reinhold at oracle.com wrote:

2018/5/16 18:31:15 -0700, martinrb at google.com:

I've been confused by NULL vs null for years.

That’s because NULL in ReferenceQueue.java refers to the singleton object ReferenceQueue.NULL, not the null value. See the long comment at the top of Reference.java for an explanation. To improve this you could change mentions of NULL in the comments to ReferenceQueue.NULL, but changing them to null would be incorrect. The comments that were changed in the proposed patch refer to the Reference.next and Reference.discovered fields, not Reference.queue. So "null" should be correct there.

Oops, you’re right! Confused by my own twenty-year old code ...

What’s missing here is a similar comment on the Reference.queue field. Suggested text:

/* When active: queue with which this reference is registered
 *     pending: queue with which this reference is registered
 *    enqueued: ReferenceQueue.ENQUEUED
 *    inactive: ReferenceQueue.NULL
 */

Martin -- while you’re at it, please lowercase “Enqueued:” and “Inactive:” in the other comments, and hard-wrap the comment on the discovered field to 80 columns.

8203327: Small cleanups in java.lang.ref http://cr.openjdk.java.net/~martin/webrevs/jdk/Reference-cleanup/ https://bugs.openjdk.java.net/browse/JDK-8203327



More information about the core-libs-dev mailing list