Null handling in XPath and XPathExpression is inconsistent. For the evaluate method that takes source, the definition is:
NullPointerException - If source or returnType is null.
For the evaluate method that accepts a context item, the specification states:
If a null value is provided for item, an empty document will be used for the context.
The later will result in javax.xml.transform.TransformerException: Unable to evaluate expression using this context, that is confusing to users since the error message is not clear with regard to the nature of the error.
In JDK-8054196, we've added several evaluateExpression methods in which the definition is clear that NullPointerException should be thrown if any of the parameters is null. I suggest we follow the same rule for the evaluate method.