提交 7d1623fb 编写于 作者: C coffeys

Merge

...@@ -3497,6 +3497,7 @@ public class Collections { ...@@ -3497,6 +3497,7 @@ public class Collections {
*/ */
@Override @Override
public void replaceAll(UnaryOperator<E> operator) { public void replaceAll(UnaryOperator<E> operator) {
Objects.requireNonNull(operator);
list.replaceAll(e -> typeCheck(operator.apply(e))); list.replaceAll(e -> typeCheck(operator.apply(e)));
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8047795 * @bug 8047795 8053938
* @summary Ensure that replaceAll operator cannot add bad elements * @summary Ensure that replaceAll operator cannot add bad elements
* @author Mike Duigou * @author Mike Duigou
*/ */
...@@ -46,5 +46,16 @@ public class CheckedListReplaceAll { ...@@ -46,5 +46,16 @@ public class CheckedListReplaceAll {
thwarted.printStackTrace(System.out); thwarted.printStackTrace(System.out);
System.out.println("Curses! Foiled again!"); System.out.println("Curses! Foiled again!");
} }
unwrapped = Arrays.asList(new Object[]{}); // Empty list
wrapped = Collections.checkedList(unwrapped, Integer.class);
try {
wrapped.replaceAll((UnaryOperator)null);
System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
throw new RuntimeException("NPE not thrown when passed a null operator");
} catch (NullPointerException thwarted) {
thwarted.printStackTrace(System.out);
System.out.println("Curses! Foiled again!");
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册