GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [java] DanglingJavadoc false positive on record compact constructors · Issue #6103 · pmd/pmd Closed Labels a:false-positivePMD flags a piece of code that is not problematic Milestone DescriptionAffects PMD Version: 7.17.0 Rule: DanglingJavadoc Description: PMD's DanglingJavadoc rule incorrectly reports Javadoc comments on Java record compact constructors as "dangling" (not belonging to any class, method, or field). Compact constructors are valid constructor declarations introduced in Java 14 (JEP 359) and should be recognized as valid Javadoc targets. Code Sample demonstrating the issue: package test; import static io.github.cowwoc.requirements12.java.DefaultJavaValidators.requireThat; /** * Represents a position in source code with line and column information. * * @param line the line number (1-based) * @param column the column number (1-based) */ public record SourcePosition(int line, int column) { /** * Compact constructor validating line and column are positive. */ public SourcePosition { requireThat(line, "line").isPositive(); requireThat(column, "column").isPositive(); } } Expected outcome: PMD should recognize the Javadoc comment as documenting the compact constructor and not report any violation. Actual outcome: PMD reports a violation at line 15: This is a false positive. The Javadoc comment documents the compact constructor Technical Context: Java records support compact constructor syntax where the parameter list is omitted: public record Point(int x, int y) { // Compact constructor - no parameter list needed public Point { if (x < 0 || y < 0) throw new IllegalArgumentException(); // Field assignments (this.x = x; this.y = y;) are implicit } } This is equivalent to the canonical constructor form: public record Point(int x, int y) { // Canonical constructor - explicit parameters public Point(int x, int y) { if (x < 0 || y < 0) throw new IllegalArgumentException(); this.x = x; this.y = y; } } PMD's DanglingJavadoc rule should recognize Running PMD through: Maven (maven-pmd-plugin 3.25.0) Activity
MetadataMetadataAssigneesLabelsa:false-positivePMD flags a piece of code that is not problematic TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |