8145459: Cleaner - use Reference.reachabilityFence
Reviewed-by: psandoz, mchung, chegar
--- 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);
+
}
/**