diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 66e1a09d77..8511bbf890 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1488,7 +1488,7 @@ void MethodDeclaration(int modifiers) : {jjtThis.setModifiers(modifiers);} { [ TypeParameters() ] - ResultType() MethodDeclarator() [ "throws" NameList() ] + [(Annotation() {checkForBadTypeAnnotations();})+] ResultType() MethodDeclarator() [ "throws" NameList() ] ( Block() | ";" ) } 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 4be5843cf9..76e310dd98 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 @@ -180,6 +180,10 @@ public class ParserCornerCases18 { public static > T getEnum() { return null; } + + public static @Nullable T getNullableEnum() { + return null; + } public Object[] createNonNullArray() { return new Object @NonNull[0];