From a4754e9fc97863850485df5999951eba6604e974 Mon Sep 17 00:00:00 2001 From: snap252 Date: Tue, 30 May 2017 15:15:44 +0200 Subject: [PATCH] I hear voices ... and they tell me to like multi dimensional arrays private static void testMultiDimArrayWithAnnotations() { // ever used a 2D-Array in java?? Object x = new Object @NonNull[2] @Nullable[1] @NonNull[3]; } --- pmd-java/etc/grammar/Java.jjt | 5 +++-- .../net/sourceforge/pmd/ast/ParserCornerCases18.java | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 4a6cfbfda7..8511bbf890 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1921,7 +1921,7 @@ void AllocationExpression(): (LOOKAHEAD(2) PrimitiveType() ArrayDimsAndInits() | - ClassOrInterfaceType() ((Annotation() {checkForBadTypeAnnotations();})*) [ TypeArguments() ] + ClassOrInterfaceType() [ TypeArguments() ] ( ArrayDimsAndInits() | @@ -1937,8 +1937,9 @@ void AllocationExpression(): void ArrayDimsAndInits() : {} { + LOOKAHEAD(2) - ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* + ( LOOKAHEAD(2) ((Annotation() {checkForBadTypeAnnotations();})*) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* | ( "[" "]" )+ ArrayInitializer() } 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 0e9df63d68..b93b5a89b5 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 @@ -184,6 +184,11 @@ public class ParserCornerCases18 { public Object createNonNullArray() { return new Object @NonNull[0]; } + + private static void testMultiDimArrayWithAnnotations() { + // ever used a 2D-Array in java?? + Object x = new Object @NonNull[2] @Nullable[1] @NonNull[3]; + } /**