From 7a4766e8a604688c46bda1bd1114a9c3c2aa9b9c Mon Sep 17 00:00:00 2001 From: Git Guru Date: Tue, 30 May 2017 10:52:09 +0200 Subject: [PATCH] [java] Parsing Problem with Annotation for Array Member Types #417 --- pmd-java/etc/grammar/Java.jjt | 2 +- .../net/sourceforge/pmd/ast/ParserCornerCases18.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index f3d9cdba16..9b2ed9cfec 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1566,7 +1566,7 @@ void ReferenceType(): { PrimitiveType() ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+ | - ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })* + ( ClassOrInterfaceType() (Annotation() {checkForBadTypeAnnotations();})*) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })* } void ClassOrInterfaceType(): diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/ast/ParserCornerCases18.java b/pmd-java/src/test/resources/net/sourceforge/pmd/ast/ParserCornerCases18.java index 7818b6f8f7..00d8237754 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/ast/ParserCornerCases18.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/ast/ParserCornerCases18.java @@ -168,6 +168,11 @@ public class ParserCornerCases18 { public List<@AnnotatedUsage ?> testWildCardWithAnnotation() { return null; } + + public Object @Nullable [] testAnnotationsToArrayElements() { + return null; + } + /** * Explicit receiver Parameters