diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceDeclarationTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceDeclarationTest.java index 44a24b7474..0390203714 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceDeclarationTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceDeclarationTest.java @@ -32,6 +32,9 @@ public class ASTClassOrInterfaceDeclarationTest { private static final String LOCAL_CLASS_WITH_MODIFIERS = "class Foo { { abstract class Local {} } }"; + private static final String LOCAL_CLASS_WITH_MIXED_MODIFIER_ANNOTATIONS + = "class Foo { { final @F class Local {} } }"; + private static final String LOCAL_CHILDREN_ARE_NOT_ALWAYS_LOCAL = "class Foo { { class Local { class Nested {} void bar() {class Local2 {}}}}}"; @@ -68,6 +71,17 @@ public class ASTClassOrInterfaceDeclarationTest { } + @Test + public void testLocalClassWithMixedModifiers() { + List classes = ParserTstUtil.getOrderedNodes(ASTClassOrInterfaceDeclaration.class, LOCAL_CLASS_WITH_MIXED_MODIFIER_ANNOTATIONS); + assertTrue(classes.size() == 2); + + assertFalse("Local class false-positive", classes.get(0).isLocal()); + assertTrue("Local class false-negative", classes.get(1).isLocal()); + assertTrue("Local class should preserve its modifiers", classes.get(1).isFinal()); + } + + @Test public void testLocalClassVisibility() {