FileContents confused about number of lines in comment separated by '\r' #3066

Closed
rnveach opened this Issue Mar 26, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@rnveach
Member

rnveach commented Mar 26, 2016

Taken from PR #3060

When the java lexer is given the comment /* \r\u0000\u0000 */ it throws an ArrayIndexOutOfBoundsException.

Code in AstRegressionTest:

verifyAstRaw(getPath("InputRegressionEmptyAst.txt"), "/* \r\u0000\u0000 */", true);

Exception:

java.lang.ArrayIndexOutOfBoundsException: 1
    at com.puppycrawl.tools.checkstyle.api.FileText.get(FileText.java:324)
    at com.puppycrawl.tools.checkstyle.api.FileContents.line(FileContents.java:224)
    at com.puppycrawl.tools.checkstyle.api.FileContents.extractCComment(FileContents.java:189)
    at com.puppycrawl.tools.checkstyle.api.FileContents.reportCComment(FileContents.java:136)
    at com.puppycrawl.tools.checkstyle.api.FileContents.reportBlockComment(FileContents.java:102)
    at com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaLexer.mBLOCK_COMMENT_BEGIN(GeneratedJavaLexer.java:1204)

Some of the cause:
Basically FileContents.extractCComment retrieved start and ends positions for the comment saying this was a 2 line comment. FileContents.line on the other hand says this is only a 1 line comment. So the exception occurs when FileContents.extractCComment tries to retrieve the non-existent second line of the comment.

@robertpainsi

This comment has been minimized.

Show comment
Hide comment
@robertpainsi

robertpainsi May 27, 2016

Contributor

Relates to #2329?

Contributor

robertpainsi commented May 27, 2016

Relates to #2329?

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach May 27, 2016

Member

@robertpainsi No.
This issue is specifically with the Java parser and its children classes. #2329 is purely with the JavaDoc antlr grammar.
The Java parser does not directly call the JavaDoc parser.

Member

rnveach commented May 27, 2016

@robertpainsi No.
This issue is specifically with the Java parser and its children classes. #2329 is purely with the JavaDoc antlr grammar.
The Java parser does not directly call the JavaDoc parser.

@robertpainsi

This comment has been minimized.

Show comment
Hide comment
@robertpainsi

robertpainsi May 28, 2016

Contributor

Ah, ok.

Contributor

robertpainsi commented May 28, 2016

Ah, ok.

rnveach added a commit to rnveach/checkstyle that referenced this issue May 29, 2016

romani added a commit that referenced this issue May 29, 2016

@romani romani added this to the 6.19 milestone May 29, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 29, 2016

Member

fix is merged.

Member

romani commented May 29, 2016

fix is merged.

@romani romani closed this May 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment