Skip to content

[java] DanglingJavadoc: False positive on /// comments for Java < 23 #6450

Closed

Description

@mebigfatguy

PMD 7.21.0

public class JD {

    public void test() {

        //// A comment
        while (true);
    }
}

This is not javadoc, so no javadoc rule infringement should be produced.

/home/dave/sample/JD.java:6: DanglingJavadoc: Javadoc comment does not belong to any class, method or field

Running PMD through: [CLI]

Activity

  1. added
    a:false-positive
    on Feb 8, 2026
  2. changed the title [-][Java]: DanglingJavadoc: reports on //// comments[/-] [+][java] DanglingJavadoc: False positive on //// comments[/+] on Feb 16, 2026
  3. adangel commented on Feb 16, 2026

    @adangel
    Member

    Thanks for reporting.

    Note, since Java 23, three slashes start a markdown javadoc comment - see JEP 467: Markdown Documentation Comments.

    I'v just tested it with Java 25, and even with your four slashes, it ends up as javadoc:

    This code

    //// Test Class
    public class Test {}

    Produces this Javadoc:

    Image

    Interestingly, the slash ends up in the documentation (which could be considered a bug in the JDK)...

    Regarding to PMD: If you call PMD and select a java version < 23, then ideally, the rule shouldn't report a violation. But for java versions >= 23, it should, as this is a valid documentation comment.

    Did you select a specific java version via --use-version?

    Since the first slash of the four slashes actually end up in the documentation, this is probably not what you want. We could create a new rule "InvalidDocumentationComment" for such cases.
    Just use the normal two slashes for a comment followed by a space, like // // A comment to be on the safe side.

  4. changed the title [-][java] DanglingJavadoc: False positive on //// comments[/-] [+][java] DanglingJavadoc: False positive on //// comments for Java < 23[/+] on Feb 16, 2026
  5. zbynek commented on Mar 28, 2026

    @zbynek
    Contributor

    @adangel the handling of /// as comment in Java <23 is something we considered and decided to keep simple:
    #5916 (review)
    If we were to fix it, should it be for this rule specifically or should we change the handling of /// in general?

    Interestingly, the slash ends up in the documentation (which could be considered a bug in the JDK)

    I think that's fine, three slashes indicate JavaDoc, fourth slash is part of the comment. Maybe IDEs could highlight it differently to make it more obvious.

  6. added a commit that references this issue on Aug 8, 2026
    b06b539
  7. victorwss commented on Aug 9, 2026

    @victorwss

    Well, I would argue that a /// comment in a pre-23 Java version is a problem that should be flagged nonetheless because code featuring this would likely break the Javadoc in Java 23+ and hence, it is a problem for a modernization/migration effort. In fact, I would be concerned with the opposite problem: Having /// javadocs in pre-23 Java.

  8. changed the title [-][java] DanglingJavadoc: False positive on //// comments for Java < 23[/-] [+][java] DanglingJavadoc: False positive on /// comments for Java < 23[/+] on Aug 14, 2026
  9. added a commit that references this issue on Aug 15, 2026
    5927caf
  10. UncleOwen commented on Sep 10, 2026

    @UncleOwen
    Member

    Well, I would argue that a /// comment in a pre-23 Java version is a problem that should be flagged nonetheless because code featuring this would likely break the Javadoc in Java 23+ and hence, it is a problem for a modernization/migration effort. In fact, I would be concerned with the opposite problem: Having /// javadocs in pre-23 Java.

    That's not what this rule is about. But sounds like a good idea for another rule.

  11. added this to the 7.28.0 milestone on Sep 10, 2026
  12. added a commit that references this issue on Sep 10, 2026
    73aa712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions