QDox
  1. QDox
  2. QDOX-242

QDox cannot parse double value in annotation element value well

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Parser
    • Labels:
      None
    • Number of attachments :
      1

      Description

      QDox parser cannot will throw following exception when encounter annotation element value in double literal:

      com.thoughtworks.qdox.parser.ParseException: syntax error @[971,96]
      	at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:1594) ~[classes/:na]
      	at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:1716) ~[classes/:na]
      	at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:1575) ~[classes/:na]
      	at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:205) ~[classes/:na]
      	at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:162) ~[classes/:na]
      	at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:91) ~[classes/:na]
      	at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:86) ~[classes/:na]
      	at com.thoughtworks.qdox.library.SortedClassLibraryBuilder.addSource(SortedClassLibraryBuilder.java:161) ~[classes/:na]
      	at com.thoughtworks.qdox.JavaProjectBuilder.addSource(JavaProjectBuilder.java:173) ~[classes/:na]
      	at gov.fia.tools.releaser.core.item.internal.QDoxUtils.loadJavaClass(QDoxUtils.java:66) ~[classes/:na]
      	at gov.fia.tools.releaser.core.item.JavaItem.readMetadata(JavaItem.java:51) ~[classes/:na]
      	... 16 common frames omitted
      

      Following is our code clip, the delta = 0.005 crashes QDox, while delta = 0.5 or delta = 0 will be ok:

          @Field(id = "04")
          @Rule.List({
              @Rule(code = "★171A021", asserts = "#07 != 0", matches = "#05 * #06 / #07", delta = 0.005,
                      precondition = "@stkhAreAddMk == '1' && #07 != 0"),
              @Rule(code = "★171A022", asserts = "#09 != 0", matches = "#08 / #09", delta = 0.005,
                      precondition = "@stkhAreAddMk == '2' && #09 != 0"),
              @Rule(code = "★171A023", asserts = "#09 != 0 && #11 != 0", matches = "(#08 / #09) + (#10 / #11)",delta = 0.005,
                      precondition = "@stkhAreAddMk == '3' && #09 != 0 && #11 != 0") })
          @Digits(fraction = 0, integer = 14)
          public BigDecimal getStkhAreAdd() {
              return prct049.getStkhAreAdd();
          }
      

        Activity

        Hide
        Pei-Tang Huang added a comment -

        This patch can resolve my problem.

        Show
        Pei-Tang Huang added a comment - This patch can resolve my problem.
        Pei-Tang Huang made changes -
        Field Original Value New Value
        Attachment lexer.flex.patch [ 61689 ]
        Robert Scholte made changes -
        Assignee Robert Scholte [ rfscholte ]
        Hide
        Robert Scholte added a comment -

        I can confirm the issue.
        One of the goals of QDox2 is to follow the Java Language Specification as close as possible.
        So it seems that we haven't covered it yet for this part and we need to work on a solution as described at http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.1

        Show
        Robert Scholte added a comment - I can confirm the issue. One of the goals of QDox2 is to follow the Java Language Specification as close as possible. So it seems that we haven't covered it yet for this part and we need to work on a solution as described at http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.1
        Hide
        Robert Scholte added a comment -

        Fixed in rev.1555 with unit-test.
        The patch was indeed the right spot to solve it. Thanks!

        Show
        Robert Scholte added a comment - Fixed in rev.1555 with unit-test. The patch was indeed the right spot to solve it. Thanks!
        Robert Scholte made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0 [ 15636 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Robert Scholte
            Reporter:
            Pei-Tang Huang
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: