Skip to content

JavadocTypeCheck incorrectly matches record component @param tags using prefix instead of exact match #19770

@Sumitkapoor129

Description

@Sumitkapoor129

I noticed that the Javadoc check does not correctly validate @param tags for record components.

Currently, it treats a tag as valid if it shares a prefix with the component name, instead of requiring an exact match. This leads to inconsistent validation results.


Steps to reproduce

  1. Create a file with the following content:
/**
 * Example case
 *
 * @param john123 wrong tag for a different component
 */
record Sample(String john) {}
  1. Use the following Checkstyle configuration:
<!DOCTYPE module PUBLIC
    "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
    "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="JavadocType"/>
    </module>
</module>
  1. Run Checkstyle:
checkstyle -c checkstyle.xml Sample.java

Expected behavior

  • @param tags should match the record component name exactly
  • A missing @param john violation should be reported

Actual behavior

  • @param john123 is treated as documenting john due to prefix-based matching
  • Missing @param john is not reported
  • john123 is still flagged as an unused tag

Why this is a problem

This creates inconsistent behavior:

  • The incorrect tag is accepted in one place
  • But rejected in another

This makes the validation confusing and unreliable.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions