AbstractIterator extends UnmodifiableIterator<T> { @Override public final T next() { if (!hasNext()) { throw new NoSuchElementException(); } state = State.NOT_READY; T result = next; next = null; return result; } protected  AbstractIterator(); @Override final boolean hasNext(); @Override final T next(); final T peek();  }
@GwtIncompatible("weak references") @Test public void testFreesNextReference() { Iterator<Object> itr = new AbstractIterator<Object>() { @Override public Object computeNext() { return new Object(); } }; WeakReference<Object> ref = new WeakReference<Object>(itr.next()); GcFinalization.awaitClear(ref); }