Checks that the order of modifiers conforms to the suggestions in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. The correct order is:
public
protected
private
abstract
static
final
transient
volatile
synchronized
native
strictfp
To configure the check:
com.puppycrawl.tools.checkstyle.checks.modifier
Checks for redundant modifiers in:
interface declarations that are declared
as static.
Rationale: The Java Language Specification strongly
discourages the usage of public and abstract for method
declarations in interface definitions as a matter of style.
Interfaces by definition are abstract so the abstract
modifier on the interface is redundant.
Variables in interfaces and annotations are automatically public, static and final, so these modifiers are redundant as well.
As annotations are a form of interface, their fields are also automatically public, static and final just as their annotation fields are automatically public and abstract.
Final classes by definition cannot be extended so the final
modifier on the method of a final class is redundant.
| name | description | type | default value |
|---|---|---|---|
| tokens | tokens to check | subset of tokens METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF | METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF |
To configure the check:
To configure the check to check only methods and not variables:
com.puppycrawl.tools.checkstyle.checks.modifier