JDK-8204959 : Predicate::not should explicitly mention "NullPointerException - if target is null"
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-06-13
  • Updated: 2018-06-13
  • Resolved: 2018-06-13
Related Reports
CSR :  
Description
Summary
-------

Report that the method throws a NullPointerException and specify that the method calls the negate method of target argument.

Problem
-------

The current Javadoc does not indicate that the method explicitly checks for a null target. Also, the method should indicate that the target Predicate's negate method is called to produce the result.

Solution
--------

Update the Javadoc.

Specification
-------------

    /**
     * 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
     *
     * @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();
    }

Comments
Moving to Approved.
13-06-2018

Moving to Provisional.
13-06-2018