8151660: Revert NativeBuffer.java to use jdk.internal.ref.Cleaner
authormchung
Thu, 10 Mar 2016 11:52:54 -0800
changeset 36438 e13192ef7946
parent 36437 16ef746c2a7b
child 36439 e0fdb6c0bb65
child 36631 1742198594f8
8151660: Revert NativeBuffer.java to use jdk.internal.ref.Cleaner Reviewed-by: rriggs
jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java
--- a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java	Thu Mar 10 09:50:58 2016 -0800
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java	Thu Mar 10 11:52:54 2016 -0800
@@ -26,9 +26,7 @@
 package sun.nio.fs;
 
 import jdk.internal.misc.Unsafe;
-import jdk.internal.ref.CleanerFactory;
-
-import java.lang.ref.Cleaner;
+import jdk.internal.ref.Cleaner;
 
 /**
  * A light-weight buffer in native memory.
@@ -39,7 +37,7 @@
 
     private final long address;
     private final int size;
-    private final Cleaner.Cleanable cleanable;
+    private final Cleaner cleaner;
 
     // optional "owner" to avoid copying
     // (only safe for use by thread-local caches)
@@ -58,7 +56,7 @@
     NativeBuffer(int size) {
         this.address = unsafe.allocateMemory(size);
         this.size = size;
-        this.cleanable = CleanerFactory.cleaner().register(this, new Deallocator(address));
+        this.cleaner = Cleaner.create(this, new Deallocator(address));
     }
 
     void release() {
@@ -74,7 +72,7 @@
     }
 
     void free() {
-        cleanable.clean();
+        cleaner.clean();
     }
 
     // not synchronized; only safe for use by thread-local caches