--- old/src/java.base/share/classes/java/lang/ref/Cleaner.java 2016-04-01 17:59:14.974072295 +0200 +++ new/src/java.base/share/classes/java/lang/ref/Cleaner.java 2016-04-01 17:59:14.856071549 +0200 @@ -29,7 +29,6 @@ import java.util.Objects; import java.util.concurrent.ThreadFactory; -import java.util.function.Function; /** * {@code Cleaner} manages a set of object references and corresponding cleaning actions. @@ -128,28 +127,7 @@ * All cleaning actions registered to a cleaner should be mutually compatible. * @since 9 */ -public final class Cleaner { - - /** - * The Cleaner implementation. - */ - final CleanerImpl impl; - - static { - CleanerImpl.setCleanerImplAccess(new Function() { - @Override - public CleanerImpl apply(Cleaner cleaner) { - return cleaner.impl; - } - }); - } - - /** - * Construct a Cleaner implementation and start it. - */ - private Cleaner() { - impl = new CleanerImpl(); - } +public interface Cleaner { /** * Returns a new {@code Cleaner}. @@ -170,10 +148,8 @@ * @throws SecurityException if the current thread is not allowed to * create or start the thread. */ - public static Cleaner create() { - Cleaner cleaner = new Cleaner(); - cleaner.impl.start(cleaner, null); - return cleaner; + static Cleaner create() { + return new CleanerImpl(null); } /** @@ -197,11 +173,9 @@ * @throws SecurityException if the current thread is not allowed to * create or start the thread. */ - public static Cleaner create(ThreadFactory threadFactory) { + static Cleaner create(ThreadFactory threadFactory) { Objects.requireNonNull(threadFactory, "threadFactory"); - Cleaner cleaner = new Cleaner(); - cleaner.impl.start(cleaner, threadFactory); - return cleaner; + return new CleanerImpl(threadFactory); } /** @@ -214,18 +188,14 @@ * @param action a {@code Runnable} to invoke when the object becomes phantom reachable * @return a {@code Cleanable} instance */ - public Cleanable register(Object obj, Runnable action) { - Objects.requireNonNull(obj, "obj"); - Objects.requireNonNull(action, "action"); - return new CleanerImpl.PhantomCleanableRef(obj, this, action); - } + Cleanable register(Object obj, Runnable action); /** * {@code Cleanable} represents an object and a * cleaning action registered in a {@code Cleaner}. * @since 9 */ - public interface Cleanable { + interface Cleanable { /** * Unregisters the cleanable and invokes the cleaning action. * The cleanable's cleaning action is invoked at most once