diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index a180a16f4f..0548fdf6d0 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,9 @@ /** + * Change lookahead for AnnotationMethodDeclaration in AnnotationTypeMemberDeclaration. + * Bug #206 + * + * Juan Martin Sotuyo Dodero 01/2017 + *==================================================================== * Allow method references to specify generics. * Bug #207 * @@ -2282,7 +2287,7 @@ void AnnotationTypeMemberDeclaration(): { modifiers = Modifiers() ( - LOOKAHEAD(3) AnnotationMethodDeclaration(modifiers) + LOOKAHEAD(Type() "(") AnnotationMethodDeclaration(modifiers) | ClassOrInterfaceDeclaration(modifiers) | 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 1a025ec9ca..4e151479e7 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 @@ -143,6 +143,15 @@ public class ParserCornersTest extends ParserTst { parseJava18(c); } + @Test + public void testBug206() throws Exception { + String code = "public @interface Foo {" + PMD.EOL + + "static final ThreadLocal> interner =" + PMD.EOL + + " ThreadLocal.withInitial(Interners::newStrongInterner);" + PMD.EOL + + "}"; + parseJava18(code); + } + /** * This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis * @throws Exception