--- old/src/java.base/share/classes/java/lang/ref/Reference.java 2016-02-21 19:30:02.333317609 +0100 +++ new/src/java.base/share/classes/java/lang/ref/Reference.java 2016-02-21 19:30:02.228319440 +0100 @@ -27,9 +27,6 @@ import jdk.internal.vm.annotation.DontInline; import jdk.internal.HotSpotIntrinsicCandidate; -import jdk.internal.misc.JavaLangRefAccess; -import jdk.internal.misc.SharedSecrets; -import jdk.internal.ref.Cleaner; /** * Abstract base class for reference objects. This class defines the @@ -139,11 +136,10 @@ } static { - // pre-load and initialize InterruptedException and Cleaner classes + // pre-load and initialize InterruptedException class // so that we don't get into trouble later in the run loop if there's - // memory shortage while loading/initializing them lazily. + // memory shortage while loading/initializing it lazily. ensureClassInitialized(InterruptedException.class); - ensureClassInitialized(Cleaner.class); } ReferenceHandler(ThreadGroup g, String name) { @@ -175,14 +171,10 @@ */ static boolean tryHandlePending(boolean waitForNotify) { Reference r; - Cleaner c; try { synchronized (lock) { - if (pending != null) { - r = pending; - // 'instanceof' might throw OutOfMemoryError sometimes - // so do this before un-linking 'r' from the 'pending' chain... - c = r instanceof Cleaner ? (Cleaner) r : null; + r = pending; + if (r != null) { // unlink 'r' from 'pending' chain pending = r.discovered; r.discovered = null; @@ -199,8 +191,6 @@ } catch (OutOfMemoryError x) { // Give other threads CPU time so they hopefully drop some live references // and GC reclaims some space. - // Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above - // persistently throws OOME for some time... Thread.yield(); // retry return true; @@ -209,12 +199,6 @@ return true; } - // Fast path for cleaners - if (c != null) { - c.clean(); - return true; - } - ReferenceQueue q = r.queue; if (q != ReferenceQueue.NULL) q.enqueue(r); return true; @@ -232,14 +216,6 @@ handler.setPriority(Thread.MAX_PRIORITY); handler.setDaemon(true); handler.start(); - - // provide access in SharedSecrets - SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() { - @Override - public boolean tryHandlePendingReference() { - return tryHandlePending(false); - } - }); } /* -- Referent accessor and setters -- */