/var/tmp $ cat checkstyle.xml
<!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="RequireThis">
<property name="validateOnlyOverlapping" value="false"/>
</module>
</module>
</module>
/var/tmp $ cat SomeAnnotation.java
public @interface SomeAnnotation {
Object A_CONSTANT_VALUE = new Object();
String value();
final class InnerClass {
public void method() {
System.out.println(A_CONSTANT_VALUE);
}
}
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.21.1-all.jar -c checkstyle.xml SomeAnnotation.java
Starting audit...
[ERROR] SomeAnnotation.java:10:26: Reference to instance variable 'A_CONSTANT_VALUE'
needs "SomeAnnotation.this.". [RequireThis]
Audit done.
Checkstyle ends with 1 errors
A_CONSTANT_VALUE isn't an instance variable, its a static one.
A_CONSTANT_VALUEisn't an instance variable, its a static one.