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

XPath parser does not accept redundant negative signs

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u16
    • Fix Version/s: None
    • Component/s: xml
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux_ubuntu

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Distributor ID: Ubuntu
        Description: Ubuntu 9.04
        Release: 9.04
      Codename: jaunty


      A DESCRIPTION OF THE PROBLEM :
      When you try to evaluate an XPath expression with redundant unary '-' signs you get a parser error. Recursive Unary-Expressions are accepted by XPath 1.0 standard

      http://www.w3.org/TR/xpath#NT-UnaryExpr
      [27] UnaryExpr ::= UnionExpr
                                       | '-' UnaryExpr

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javax.xml.xpath.XPathFactory.newInstance().newXPath().evaluate("--2",(Object)null)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should return "2"
      ACTUAL -
      javax.xml.transform.TransformerException: A location path was expected, but the following token was encountered: -


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" javax.xml.transform.TransformerException: A location path was expected, but the following token was encountered: -
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:608)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(XPathParser.java:1599)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1315)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1234)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1140)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1061)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:1003)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:928)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:868)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:832)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:805)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:788)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:127)
      at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:176)
      at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:264)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(XPathImpl.java:193)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:275)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:365)
      at oracle.bpm.project.compiler.test.Test.main(Test.java:19)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
      --------------- linked to ------------------
      javax.xml.xpath.XPathExpressionException
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:289)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:365)
      at oracle.bpm.project.compiler.test.Test.main(Test.java:19)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
      Caused by: javax.xml.transform.TransformerException: A location path was expected, but the following token was encountered: -
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:608)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(XPathParser.java:1599)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1315)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1234)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1140)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1061)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:1003)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:928)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:868)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:832)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:805)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:788)
      at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:127)
      at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:176)
      at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:264)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(XPathImpl.java:193)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:275)
      ... 7 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.xml.xpath.XPathFactory;

      public class Test
      {
          public static void main(String[] args) throws Exception
          {
              System.out.println(XPathFactory.newInstance().newXPath().evaluate("--2",(Object)null));
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use redundant "-" signs

        Attachments

          Activity

            People

            • Assignee:
              joehw Joe Wang
              Reporter:
              ndcosta Nelson Dcosta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: