src/java.base/share/classes/java/lang/ref/ReferenceQueue.java
changeset 50277 f84ae8aa5d88
parent 47216 71c04702a3d5
child 50301 fe42de5250f3
--- a/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java	Fri May 25 14:10:21 2018 -0700
+++ b/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java	Sat May 26 03:11:50 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,7 @@
                 return false;
             }
             assert queue == this;
+            // Self-loop end, so if a FinalReference it remains inactive.
             r.next = (head == null) ? r : head;
             head = r;
             queueLength++;
@@ -90,7 +91,10 @@
             // poll().  Volatiles ensure ordering.
             @SuppressWarnings("unchecked")
             Reference<? extends T> rn = r.next;
+            // Handle self-looped next as end of list designator.
             head = (rn == r) ? null : rn;
+            // Self-loop next rather than setting to null, so if a
+            // FinalReference it remains inactive.
             r.next = r;
             queueLength--;
             if (r instanceof FinalReference) {