diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java index c39e293399b..27fb1b1ac12 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java14PreviewTest.java @@ -113,7 +113,7 @@ public void recordPointBeforeJava14PreviewShouldFail() { public void innerRecords() { ASTCompilationUnit compilationUnit = java14p.parseResource("Records.java"); List recordDecls = compilationUnit.findDescendantsOfType(ASTRecordDeclaration.class, true); - Assert.assertEquals(6, recordDecls.size()); + Assert.assertEquals(7, recordDecls.size()); ASTRecordDeclaration complex = recordDecls.get(0); Assert.assertEquals("MyComplex", complex.getName()); @@ -152,6 +152,11 @@ public void innerRecords() { ASTRecordDeclaration emptyRec = recordDecls.get(5); Assert.assertEquals("EmptyRec", emptyRec.getName()); Assert.assertEquals(0, emptyRec.getRecordComponents().size()); + + ASTRecordDeclaration personRec = recordDecls.get(6); + Assert.assertEquals("PersonRecord", personRec.getName()); + ASTImplementsList impl = personRec.getFirstChildOfType(ASTImplementsList.class); + Assert.assertEquals(2, impl.findChildrenOfType(ASTClassOrInterfaceType.class).size()); } @Test(expected = ParseException.class) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/Records.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/Records.java index 1da89157911..24be2863034 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/Records.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/Records.java @@ -47,4 +47,12 @@ public static void baz() { System.out.println(r); } } + + // see https://www.javaspecialists.eu/archive/Issue276.html + public interface Person { + String firstName(); + String lastName(); + } + public record PersonRecord(String firstName, String lastName) + implements Person, java.io.Serializable { } }