Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4971613

XPathExpression.evaluate() throws IAE in case of simple expressions

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description



        Name: eaR10174 Date: 12/22/2003


        The method

             javax.xml.xpath.XPathExpression.evaluate(Object, QName)

        throws IllegalArgumentException evaluating simple expressions in the absence of a context item.
        The sample below shows failure with the "1+1" expression. According to the javadoc
        the method should not throw IAE in such cases.

        The bug affects new JCK1.5 tests:

           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate010]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate011]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate012]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate013]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate014]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate015]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate016]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate017]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate018]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate019]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate020]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate021]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate022]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate023]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate024]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate025]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate026]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate027]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate028]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate030]

        The following test fails running on JDK 1.5.0-beta-b32.
        See below the test source and the execution log:
        ------------------------------------test.java-----------------------------
        import javax.xml.xpath.XPath;
        import javax.xml.xpath.XPathFactory;
        import javax.xml.xpath.XPathConstants;
        import javax.xml.xpath.XPathExpression;

        public class test {

             public static void main (String[] args) {
                 try {
                     XPathFactory xpf = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
                     XPath xpath = xpf.newXPath();
                     XPathExpression expr = xpath.compile("1+1");
                     expr.evaluate((Object)null, XPathConstants.NUMBER);
                 } catch (Exception e) {
                     e.printStackTrace();
                     System.exit(1);
                 }
             }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

        java.lang.IllegalArgumentException: Node must be non-null for getDTMHandleFromNode
        at
        com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault.getDTMHandleFromNode(DTMManagerDefault.java:512)
        at com.sun.org.apache.xpath.internal.XPathContext.getDTMHandleFromNode(XPathContext.java:192)
        at com.sun.org.apache.xpath.internal.XPath.execute(XPath.java:272)
        at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:66)
        at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:118)
        at test.main(test.java:13)
        --------------------------------------------------------------------------

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                rmandavasunw Ramesh Mandava (Inactive)
                Reporter:
                evgsunw Evg Evg (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: