--- old/src/java.base/share/classes/java/util/Collections.java 2018-06-25 18:02:49.115549305 -0700 +++ new/src/java.base/share/classes/java/util/Collections.java 2018-06-25 18:02:48.719549298 -0700 @@ -1569,7 +1569,8 @@ super((Set)s); } - static Consumer> entryConsumer(Consumer> action) { + static Consumer> entryConsumer( + Consumer> action) { return e -> action.accept(new UnmodifiableEntry<>(e)); } @@ -1661,6 +1662,9 @@ public void remove() { throw new UnsupportedOperationException(); } + public void forEachRemaining(Consumer> action) { + i.forEachRemaining(entryConsumer(action)); + } }; } @@ -3081,7 +3085,11 @@ return new Iterator() { public boolean hasNext() { return it.hasNext(); } public E next() { return it.next(); } - public void remove() { it.remove(); }}; + public void remove() { it.remove(); } + public void forEachRemaining(Consumer action) { + it.forEachRemaining(action); + } + }; } public boolean add(E e) { return c.add(typeCheck(e)); } @@ -3757,7 +3765,6 @@ public Iterator> iterator() { final Iterator> i = s.iterator(); - final Class valueType = this.valueType; return new Iterator>() { public boolean hasNext() { return i.hasNext(); } @@ -3766,6 +3773,11 @@ public Map.Entry next() { return checkedEntry(i.next(), valueType); } + + public void forEachRemaining(Consumer> action) { + i.forEachRemaining( + e -> action.accept(checkedEntry(e, valueType))); + } }; }