8204172: Predicate::not should explicitly mention "NullPointerException - if target is null"
Reviewed-by: sundar, psandoz, dfuchs
--- a/src/java.base/share/classes/java/util/function/Predicate.java Thu Jun 14 13:16:21 2018 +0200
+++ b/src/java.base/share/classes/java/util/function/Predicate.java Thu Jun 14 09:38:31 2018 -0300
@@ -119,6 +119,8 @@
/**
* Returns a predicate that is the negation of the supplied predicate.
+ * This is accomplished by returning result of the calling
+ * {@code target.negate()}.
*
* @param <T> the type of arguments to the specified predicate
* @param target predicate to negate
@@ -126,10 +128,13 @@
* @return a predicate that negates the results of the supplied
* predicate
*
+ * @throws NullPointerException if target is null
+ *
* @since 11
*/
@SuppressWarnings("unchecked")
static <T> Predicate<T> not(Predicate<? super T> target) {
+ Objects.requireNonNull(target);
return (Predicate<T>)target.negate();
}
}