Skip to content

[java] Fix in Java grammar: Try with final resource node error#675

Merged
jsotuyod merged 1 commit into
pmd:masterfrom
gibarsin:fixTryWithFinalResource
Oct 18, 2017
Merged

[java] Fix in Java grammar: Try with final resource node error#675
jsotuyod merged 1 commit into
pmd:masterfrom
gibarsin:fixTryWithFinalResource

Conversation

@gibarsin

Copy link
Copy Markdown
Contributor

Issue

When running the designer with the following code: https://pastebin.com/xGrHQ3QN I noticed that the Resource node contained in the Resources node has its isFinal boolean value set to false. After checking the grammar, I noticed the issue here:

LOOKAHEAD(2) ( ( "final" | Annotation() )* Type() VariableDeclaratorId() "=" Expression() )

How I solved it

When a final token is found, the isFinal value is currently not set to true. The solution is to invoke {jjtThis.setFinal(true);} to the right of "final"

@jsotuyod jsotuyod self-assigned this Oct 18, 2017
@jsotuyod jsotuyod added this to the 6.0.0 milestone Oct 18, 2017
@jsotuyod jsotuyod added the a:bug PMD crashes or fails to analyse a file. label Oct 18, 2017
@jsotuyod

Copy link
Copy Markdown
Member

@gibarsin very nice find!

@jsotuyod

jsotuyod commented Oct 18, 2017

Copy link
Copy Markdown
Member

This reminded me we are missing cases on java-unnecessarycode/UnnecessaryFinalModifier, I just added #676 to track it

@jsotuyod jsotuyod merged commit c00400e into pmd:master Oct 18, 2017
jsotuyod added a commit that referenced this pull request Oct 18, 2017
@jsotuyod

Copy link
Copy Markdown
Member

Merged for 6.0.0! Thanks for the PR!

@gibarsin gibarsin deleted the fixTryWithFinalResource branch October 18, 2017 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:bug PMD crashes or fails to analyse a file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants