Details
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.
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | qdox114.patch [ 32710 ] | |
Attachment | FieldsTest.java [ 32711 ] |
Resolution | Fixed [ 1 ] | |
Assignee | Paul Hammant [ paul ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Fix Version/s | 1.7 [ 11160 ] |
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.