JDK-8066039 : XPath: inconsistent definition for evaluate methods in XPath and XPathExpression with regard to null value
  • Type: Enhancement
  • Component: xml
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2014-11-26
  • Updated: 2017-05-19
  • Resolved: 2014-12-04
Related Reports
Relates :  
Description
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.
Comments
A null value is allowed for the context.
04-12-2014