changeset 35278:9cadaa13225e

8145459: Cleaner - use Reference.reachabilityFence Reviewed-by: psandoz, mchung, chegar
author rriggs
date Wed, 20 Jan 2016 11:33:28 -0500
parents eb4794f43d20
children 30eaec7fded0
files jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java
diffstat 3 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java	Wed Jan 20 07:36:42 2016 -0500
+++ b/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java	Wed Jan 20 11:33:28 2016 -0500
@@ -26,6 +26,7 @@
 package jdk.internal.ref;
 
 import java.lang.ref.Cleaner;
+import java.lang.ref.Reference;
 import java.lang.ref.PhantomReference;
 import java.util.Objects;
 
@@ -66,9 +67,9 @@
         this.list = CleanerImpl.getCleanerImpl(cleaner).phantomCleanableList;
         insert();
 
-        // TODO: Replace getClass() with ReachabilityFence when it is available
-        cleaner.getClass();
-        referent.getClass();
+        // Ensure referent and cleaner remain accessible
+        Reference.reachabilityFence(referent);
+        Reference.reachabilityFence(cleaner);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java	Wed Jan 20 07:36:42 2016 -0500
+++ b/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java	Wed Jan 20 11:33:28 2016 -0500
@@ -26,6 +26,7 @@
 package jdk.internal.ref;
 
 import java.lang.ref.Cleaner;
+import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
 import java.util.Objects;
 
@@ -66,9 +67,9 @@
         list = CleanerImpl.getCleanerImpl(cleaner).softCleanableList;
         insert();
 
-        // TODO: Replace getClass() with ReachabilityFence when it is available
-        cleaner.getClass();
-        referent.getClass();
+        // Ensure referent and cleaner remain accessible
+        Reference.reachabilityFence(referent);
+        Reference.reachabilityFence(cleaner);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java	Wed Jan 20 07:36:42 2016 -0500
+++ b/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java	Wed Jan 20 11:33:28 2016 -0500
@@ -26,6 +26,7 @@
  */
 
 import java.lang.ref.Cleaner;
+import java.lang.ref.Reference;
 import java.lang.ref.WeakReference;
 import java.util.Objects;
 
@@ -66,9 +67,10 @@
         list = CleanerImpl.getCleanerImpl(cleaner).weakCleanableList;
         insert();
 
-        // TODO: Replace getClass() with ReachabilityFence when it is available
-        cleaner.getClass();
-        referent.getClass();
+        // Ensure referent and cleaner remain accessible
+        Reference.reachabilityFence(referent);
+        Reference.reachabilityFence(cleaner);
+
     }
 
     /**