diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 9b2ed9cfec..564935c03c 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1435,8 +1435,8 @@ void ClassOrInterfaceBodyDeclaration(): | LOOKAHEAD(3) EnumDeclaration(modifiers) | LOOKAHEAD( [ TypeParameters() ] "(" ) ConstructorDeclaration(modifiers) | LOOKAHEAD( Type() ( "[" "]" )* ( "," | "=" | ";" ) ) FieldDeclaration(modifiers) - | MethodDeclaration(modifiers) - | AnnotationTypeDeclaration(modifiers) + | LOOKAHEAD(2) MethodDeclaration(modifiers) + | LOOKAHEAD(2) AnnotationTypeDeclaration(modifiers) ) | ";" @@ -1488,7 +1488,7 @@ void MethodDeclaration(int modifiers) : {jjtThis.setModifiers(modifiers);} { [ TypeParameters() ] - ResultType() MethodDeclarator() [ "throws" NameList() ] + [(Annotation() {checkForBadTypeAnnotations();})+] ResultType() MethodDeclarator() [ "throws" NameList() ] ( Block() | ";" ) } @@ -1564,9 +1564,9 @@ void Type(): void ReferenceType(): {} { - PrimitiveType() ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+ + PrimitiveType() ((Annotation() {checkForBadTypeAnnotations();})*) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+ | - ( ClassOrInterfaceType() (Annotation() {checkForBadTypeAnnotations();})*) ( 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 00d8237754..ad7ea6f0a1 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 @@ -172,6 +172,10 @@ public class ParserCornerCases18 { public Object @Nullable [] testAnnotationsToArrayElements() { return null; } + + private byte @Nullable [] getBytes(){ + return null; + } /**