QDox
  1. QDox
  2. QDOX-114

Parsing "new byte[1 << 16]" fails

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.7
    • Component/s: Parser
    • Labels:
      None
    • Environment:
      qdox-1.6.1
    • Testcase included:
      yes
    • Number of attachments :
      3

      Description

      Parsing attached class fails with this stacktrace:

      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] syntax error @[4,1] in file:/s:/src/sling/jasper-day/src/main/java/QDoxTest.java
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      com.thoughtworks.qdox.parser.ParseException: syntax error @[4,1] in file:/s:/src/sling/jasper-day/src/main/java/QDoxTest.java
      at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:638)
      at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:747)
      at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:619)
      at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:300)
      at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:316)
      at com.thoughtworks.qdox.JavaDocBuilder.addSource(JavaDocBuilder.java:312)
      at com.thoughtworks.qdox.JavaDocBuilder$1.visitFile(JavaDocBuilder.java:369)
      at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:43)
      at com.thoughtworks.qdox.directorywalker.DirectoryScanner.walk(DirectoryScanner.java:34)
      at com.thoughtworks.qdox.directorywalker.DirectoryScanner.scan(DirectoryScanner.java:52)
      at com.thoughtworks.qdox.JavaDocBuilder.addSourceTree(JavaDocBuilder.java:366)

      Using parser debugging I found out, that the construct

      new byte[1 << 16]

      is the culprit. Changing this to

      new byte[0x10000]

      parses without problems.

      1. FieldsTest.java
        1 kB
        Louis R. Marascio
      2. qdox114.patch
        2 kB
        Louis R. Marascio
      3. QDoxTest.java
        0.1 kB
        Felix Meschberger

        Activity

        Hide
        Louis R. Marascio added a comment -

        Appears to be an error in the lexer. The following also fails:

        {pre}
        public class X { Object b = new Object(); int a = 1 << 30; }{pre}

        This is because the lexer does not reset it's state when it leaves a 'new block' and it does not properly account for when it is within a square bracket. In these situations < and > are not handled properly.

        The attached patch fixes this issue. Please note, I have added a new file, FieldTest.java, with appropriate test cases for these field assignment scenarios. I didn't see an existing file that related to fields, thus the addition.

        Show
        Louis R. Marascio added a comment - Appears to be an error in the lexer. The following also fails: {pre} public class X { Object b = new Object(); int a = 1 << 30; }{pre} This is because the lexer does not reset it's state when it leaves a 'new block' and it does not properly account for when it is within a square bracket. In these situations < and > are not handled properly. The attached patch fixes this issue. Please note, I have added a new file, FieldTest.java, with appropriate test cases for these field assignment scenarios. I didn't see an existing file that related to fields, thus the addition.
        Hide
        Louis R. Marascio added a comment -

        Patch to lexer.flex and a new unit test file for testing the changes.

        All patch files and a readme can be found at: http://svn.fitnr.com/public/trunk/patches/qdox/qdox-114/

        Show
        Louis R. Marascio added a comment - Patch to lexer.flex and a new unit test file for testing the changes. All patch files and a readme can be found at: http://svn.fitnr.com/public/trunk/patches/qdox/qdox-114/
        Louis R. Marascio made changes -
        Field Original Value New Value
        Attachment qdox114.patch [ 32710 ]
        Attachment FieldsTest.java [ 32711 ]
        Hide
        Paul Hammant added a comment -

        fixed. thanks for the patch

        Show
        Paul Hammant added a comment - fixed. thanks for the patch
        Paul Hammant made changes -
        Resolution Fixed [ 1 ]
        Assignee Paul Hammant [ paul ]
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 1.7 [ 11160 ]
        Hide
        Paul Hammant added a comment -

        Can someone update this patch to 'svn diff' please.

        Show
        Paul Hammant added a comment - Can someone update this patch to 'svn diff' please.
        Hide
        Paul Hammant added a comment -

        ignore me

        Show
        Paul Hammant added a comment - ignore me

          People

          • Assignee:
            Paul Hammant
            Reporter:
            Felix Meschberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: