diff -r 07eb2231b946 openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java --- a/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java Wed Jul 23 13:50:19 2014 +0200 +++ b/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java Thu Jul 24 13:21:10 2014 +0200 @@ -45,7 +45,6 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; -import java.lang.reflect.Field; import java.util.logging.Level; import java.util.logging.Logger; @@ -75,33 +74,6 @@ } private static final class Impl extends ReferenceQueue { - private static final Field LOCK; - static { - Field f = null; - try { - f = ReferenceQueue.class.getDeclaredField("lock"); // NOI18N - f.setAccessible(true); - } catch (Throwable ex) { - reportError(ex); - } - LOCK = f; - } - private final Object myLock; - - Impl() { - Object l = this; - try { - if (LOCK != null) { - LOCK.set(this, l = LOCK.get(ACTIVE)); - } - } catch (IllegalArgumentException ex) { - reportError(ex); - } catch (IllegalAccessException ex) { - reportError(ex); - } - myLock = l; - } - @Override public Reference poll() { throw new UnsupportedOperationException(); @@ -117,10 +89,6 @@ throw new InterruptedException(); } - final Object lock() { - return myLock; - } - final Reference pollSuper() throws IllegalArgumentException, InterruptedException { return super.poll(); } @@ -166,19 +134,10 @@ public void run() { while (true) { try { - Impl impl = obtainQueue(); - if (impl == null) { + if (obtainQueue() == null) { return; } - Reference ref; - synchronized (impl.lock()) { - ref = impl.pollSuper(); - impl = null; - if (ref == null) { - ACTIVE.remove(Integer.MAX_VALUE); - continue; - } - } + Reference ref = ReferenceQueue.removeWhileExists(activeReferenceQueue, 0L); LOGGER.finer("dequeued reference"); if (!(ref instanceof Runnable)) { LOGGER.log(Level.WARNING, "A reference not implementing runnable has been added to the Utilities.activeReferenceQueue(): {0}", ref.getClass()); @@ -204,8 +163,4 @@ } } } - private static T reportError(T ex) throws IllegalStateException { - LOGGER.log(Level.WARNING, "Cannot hack ReferenceQueue to fix bug #206621!", ex); - return ex; - } }