Since Checkstyle 3.0
public
protected
private
abstract
default
static
sealed
non-sealed
final
transient
volatile
synchronized
native
strictfp
In additional, modifiers are checked to ensure all annotations are declared before all other modifiers.
Rationale: Code is easier to read if everybody follows a standard.
ATTENTION: We skip type annotations from validation.
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="ModifierOrder"/>
</module>
</module>
Code:
public class Example1 {
public static final int MAX_VALUE = 100;
// violation below "'private' modifier out of order with the JLS suggestions"
final private String example = "Example";
//violation below, 'annotation modifier does not precede non-annotation modifiers'
public @Deprecated class Example {}
}
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.modifier