Skip to content

InvalidJavadocPosition false-positive for record compact constructor with package-private accessibility #17158

@cowwoc

Description

@cowwoc

I have read check documentation: https://checkstyle.org/checks/javadoc/invalidjavadocposition.html#InvalidJavadocPosition
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

javac com\company\Testcase.java
java -jar checkstyle-10.25.0-all.jar -c /sun_checks.xml com\company\Testcase.java
Starting audit...
[ERROR] C:\Users\Gili\Documents\docker\core\src\main\java\com\company\Testcase.java:14:5: Javadoc comment is placed in the wrong location. [InvalidJavadocPosition]
Audit done.
Checkstyle ends with 1 errors.
java -jar checkstyle-10.25.0-all.jar -c /google_checks.xml com\company\Testcase.java
Starting audit...
[WARN] C:\Users\Gili\Documents\docker\core\src\main\java\com\company\Testcase.java:14:5: Javadoc comment is placed in the wrong location. [InvalidJavadocPosition]
Audit done.
type com\company\Testcase.java
package com.company;

/**
 * Some description.
 */
public class Testcase {
  /**
   * The configuration of a bind mount.
   *
   * @param containerPath a path on the container
   * @param options       mounting options
   */
  record BindMount(String containerPath, String... options) {
    /**
     * Creates a mount.
     *
     * @param containerPath a path on the container
     * @param options       mounting options
     * @throws NullPointerException     if any of the arguments are null
     */
    BindMount {
    }
  }
}

Describe what you expect in detail.
No warnings or errors.


PS: If you use a canonical constructor instead of a compact constructor, the error goes away. Similarly, if you use public accessibility instead of package-protected, the error goes away.

<module name="InvalidJavadocPosition"/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions