#21600·checkstyle

`EmptyLineSeparator` with `allowMultipleEmptyLines` as `false` does not report a violation if there is Javadoc then an annotation before a method

Author: james-baker-aeraCreated Sep 15, 2026Updated Sep 15, 2026
Labelsapproved

I have read check documentation: https://checkstyle.org/checks/whitespace/emptylineseparator.html 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

bash
/var/tmp $ javac Example.java
bash
/var/tmp $ cat config.xml
<?xml version="1.0"?>
<!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="EmptyLineSeparator">
            <property name="allowMultipleEmptyLines" value="false"/>
        </module>
    </module>
</module>
bash
/var/tmp $ cat Example.java 
class Example {
    void a() {
    }


    /** Javadoc. */
    @Deprecated
    void b() {
    }
}

[!NOTE] 2 blank lines between a() and b()

bash
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
bash
/var/tmp $ java $RUN_LOCALE -jar checkstyle-14.1.0-all.jar -c config.xml Example.java
Starting audit...
Audit done.

Describe what you expect in detail.

Because there are two blank lines between a() and b(), I would expect a violation.

A violation is correctly reported when the annotation is before the Javadoc.

bash
/var/tmp $ javac AnotherExample.java
bash
/var/tmp $ cat AnotherExample.java
class AnotherExample {
    void a() {
    }


    @Deprecated
    /** Javadoc. */
    void b() {
    }
}
bash
/var/tmp $ java $RUN_LOCALE -jar checkstyle-14.1.0-all.jar -c config.xml AnotherExample.java
Starting audit...
[ERROR] /var/tmp/AnotherExample.java:6:5: 'METHOD_DEF' has more than 1 empty lines before. [EmptyLineSeparator]
Audit done.
Checkstyle ends with 1 errors.