diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 23e1138ed7..b098b951c0 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,9 @@ /** + * Allow method references to specify generics. + * Bug #207 + * + * Juan Martin Sotuyo Dodero 01/2017 + *==================================================================== * Simplify VariableDeclaratorId, forbidding illegal sequences such as * this[] and MyClass.this[] * @@ -1812,7 +1817,7 @@ Token t; void MethodReference() : {Token t; checkForBadMethodReferenceUsage();} { - "::" ("new" {jjtThis.setImage("new");} | t= {jjtThis.setImage(t.image);} ) + "::" ("new" {jjtThis.setImage("new");} | [TypeArguments()] t= {jjtThis.setImage(t.image);} ) } void PrimaryPrefix() : 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 c06e00a11a..467d26e990 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 @@ -136,6 +136,12 @@ public class ParserCornersTest extends ParserTst { String c = IOUtils.toString(this.getClass().getResourceAsStream("Bug1530.java")); parseJava18(c); } + + @Test + public void testGitHubBug207() throws Exception { + String c = IOUtils.toString(this.getClass().getResourceAsStream("GitHubBug207.java")); + parseJava18(c); + } /** * This triggered bug #1484 UnusedLocalVariable - false positive - diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug207.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug207.java new file mode 100644 index 0000000000..63bd151c29 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/GitHubBug207.java @@ -0,0 +1,5 @@ +public class GitHubBug207 { + private static HttpMessageWriter resourceHttpMessageWriter(BodyInserter.Context context) { + return context.map(BodyInserters::cast); + } +} \ No newline at end of file diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index b91ea27d68..7f6b5c22e9 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -235,6 +235,7 @@ to avoid XSS attacks. * [#183](https://github.com/pmd/pmd/issues/183): \[apex] NCSS Method length is incorrect when using method chaining * java * [#185](https://github.com/pmd/pmd/issues/185): \[java] CPD runs into NPE when analyzing Lucene + * [#207](https://github.com/pmd/pmd/issues/207): \[java] Parse error on method reference with generics * [#213](https://github.com/pmd/pmd/issues/213): \[java] CPD: OutOfMemory when analyzing Lucene * [#1542](https://sourceforge.net/p/pmd/bugs/1542/): \[java] CPD throws an NPE when parsing enums with -ignore-identifiers * [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes