8193780: (ref) Remove the undocumented "jdk.lang.ref.disableClearBeforeEnqueue" system property
authormchung
Thu, 21 Dec 2017 15:04:45 -0800
changeset 48360 2731c0ee46a9
parent 48359 91bd550551e0
child 48361 e5a3b905622e
8193780: (ref) Remove the undocumented "jdk.lang.ref.disableClearBeforeEnqueue" system property Reviewed-by: alanb
src/java.base/share/classes/java/lang/ref/Reference.java
test/jdk/java/lang/ref/ReferenceEnqueue.java
--- a/src/java.base/share/classes/java/lang/ref/Reference.java	Thu Dec 21 15:58:45 2017 -0500
+++ b/src/java.base/share/classes/java/lang/ref/Reference.java	Thu Dec 21 15:04:45 2017 -0800
@@ -141,14 +141,6 @@
     }
 
     /*
-     * system property to disable clearing before enqueuing.
-     */
-    private static final class ClearBeforeEnqueue {
-        static final boolean DISABLE =
-            Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
-    }
-
-    /*
      * Atomically get and clear (set to null) the VM's pending list.
      */
     private static native Reference<Object> getAndClearReferencePendingList();
@@ -299,8 +291,7 @@
      *           it was not registered with a queue when it was created
      */
     public boolean enqueue() {
-        if (!ClearBeforeEnqueue.DISABLE)
-            this.referent = null;
+        this.referent = null;
         return this.queue.enqueue(this);
     }
 
--- a/test/jdk/java/lang/ref/ReferenceEnqueue.java	Thu Dec 21 15:58:45 2017 -0500
+++ b/test/jdk/java/lang/ref/ReferenceEnqueue.java	Thu Dec 21 15:04:45 2017 -0800
@@ -25,7 +25,6 @@
  * @bug 4268317 8132306 8175797
  * @summary Test if Reference.enqueue() works properly with GC
  * @run main ReferenceEnqueue
- * @run main/othervm -Djdk.lang.ref.disableClearBeforeEnqueue=true ReferenceEnqueue
  */
 
 import java.lang.ref.*;
@@ -87,8 +86,6 @@
         final ReferenceQueue<Object> queue = new ReferenceQueue<>();
         final List<Reference<Object>> refs = new ArrayList<>();
         final int iterations = 1000;
-        final boolean disableClearBeforeEnqueue =
-            Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
 
         ExplicitEnqueue() {
             this.refs.add(new SoftReference<>(new Object(), queue));
@@ -101,10 +98,7 @@
                 if (ref.enqueue() == false) {
                     throw new RuntimeException("Error: enqueue failed");
                 }
-                if (disableClearBeforeEnqueue && ref.get() == null) {
-                    throw new RuntimeException("Error: clearing should be disabled");
-                }
-                if (!disableClearBeforeEnqueue && ref.get() != null) {
+                if (ref.get() != null) {
                     throw new RuntimeException("Error: referent must be cleared");
                 }
             }