diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 0548fdf6d0..3e6f53a932 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,9 @@ /** + * Allow local classes to carry more than one annotation. + * Bug #208 + * + * Juan Martin Sotuyo Dodero 01/2017 + *==================================================================== * Change lookahead for AnnotationMethodDeclaration in AnnotationTypeMemberDeclaration. * Bug #206 * @@ -1978,7 +1983,7 @@ void BlockStatement(): ClassOrInterfaceDeclaration, but that seems like a hack that could break other things... */ - LOOKAHEAD( [Annotation()] ["final"|"abstract"] "class") [Annotation()] ClassOrInterfaceDeclaration(0) + LOOKAHEAD( (Annotation())* ["final"|"abstract"] "class") (Annotation())* ClassOrInterfaceDeclaration(0) } void LocalVariableDeclaration() : diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ParserCornersTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ParserCornersTest.java index 4e151479e7..9a0b20d366 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ParserCornersTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ParserCornersTest.java @@ -152,6 +152,12 @@ public class ParserCornersTest extends ParserTst { parseJava18(code); } + @Test + public void testGitHubBug208ParseError() throws Exception { + String c = IOUtils.toString(this.getClass().getResourceAsStream("GitHubBug208.java")); + parseJava15(c); + } + /** * This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis * @throws Exception diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug208.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug208.java new file mode 100644 index 0000000000..df790a09ff --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug208.java @@ -0,0 +1,11 @@ +public class GitHubBug208 { + public void testMethod() { + @Lazy + @Configuration + class LocalClass { + @Bean Object foo() { + return null; + } + } + } +} \ No newline at end of file