Since Checkstyle 8.23


Checks that Javadocs are located at the correct position. As specified at Documentation Comment Specification for the Standard Doclet, Javadocs are recognized only when placed immediately before module, package, class, interface, constructor, method, or field declarations. Any other position, like in the body of a method, will be ignored by the javadoc tool and is considered invalid by this check.


To configure the check:

<module name="Checker">
  <module name="TreeWalker">
    <module name="InvalidJavadocPosition"/>

The following code produces a violation because Javadocs should be before all annotations of the Javadoc's target:

// violation below, 'Javadoc comment is placed in the wrong location'
 * This comment looks like Javadoc but it is at an invalid location.
 * Therefore, the text will not get into TestClass.html.
 * And, the check will produce a violation.
public class Example1 {

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.


Parent Module