From 182ba02f3bb84428eb2f131e97938d7795cf7409 Mon Sep 17 00:00:00 2001 From: mduigou Date: Fri, 27 Sep 2013 13:30:31 -0700 Subject: [PATCH] 8023339: Refined Collection.removeIf UOE conditions Reviewed-by: mduigou Contributed-by: paul.sandoz@oracle.com --- src/share/classes/java/util/Collection.java | 11 ++++++----- test/java/util/Collection/MOAT.java | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/share/classes/java/util/Collection.java b/src/share/classes/java/util/Collection.java index dba273e68..8e8fd5a76 100644 --- a/src/share/classes/java/util/Collection.java +++ b/src/share/classes/java/util/Collection.java @@ -379,8 +379,8 @@ public interface Collection extends Iterable { /** * Removes all of the elements of this collection that satisfy the given - * predicate. Errors or runtime exceptions thrown by the predicate are - * relayed to the caller. + * predicate. Errors or runtime exceptions thrown during iteration or by + * the predicate are relayed to the caller. * * @implSpec * The default implementation traverses all elements of the collection using @@ -393,9 +393,10 @@ public interface Collection extends Iterable { * removed * @return {@code true} if any elements were removed * @throws NullPointerException if the specified filter is null - * @throws UnsupportedOperationException if the {@code remove} - * method is not supported by this collection's - * {@link #iterator} + * @throws UnsupportedOperationException if elements cannot be removed + * from this collection. Implementations may throw this exception if a + * matching element cannot be removed or if, in general, removal is not + * supported. * @since 1.8 */ default boolean removeIf(Predicate filter) { diff --git a/test/java/util/Collection/MOAT.java b/test/java/util/Collection/MOAT.java index a039461e2..945335a7f 100644 --- a/test/java/util/Collection/MOAT.java +++ b/test/java/util/Collection/MOAT.java @@ -207,8 +207,8 @@ public class MOAT { new Fun(){void f(){ it.next(); }}); try { it.remove(); } - catch (IllegalStateException _) { pass(); } - catch (UnsupportedOperationException _) { pass(); } + catch (IllegalStateException ignored) { pass(); } + catch (UnsupportedOperationException ignored) { pass(); } catch (Throwable t) { unexpected(t); } if (rnd.nextBoolean()) @@ -280,9 +280,9 @@ public class MOAT { testEmptyCollection(m.values()); try { check(! m.containsValue(null)); } - catch (NullPointerException _) { /* OK */ } + catch (NullPointerException ignored) { /* OK */ } try { check(! m.containsKey(null)); } - catch (NullPointerException _) { /* OK */ } + catch (NullPointerException ignored) { /* OK */ } check(! m.containsValue(1)); check(! m.containsKey(1)); } @@ -710,8 +710,8 @@ public class MOAT { l.addAll(-1, Collections.emptyList()); fail("Expected IndexOutOfBoundsException not thrown"); } - catch (UnsupportedOperationException _) {/* OK */} - catch (IndexOutOfBoundsException _) {/* OK */} + catch (UnsupportedOperationException ignored) {/* OK */} + catch (IndexOutOfBoundsException ignored) {/* OK */} catch (Throwable t) { unexpected(t); } // equal(l instanceof Serializable, -- GitLab