Checkstyle Modifiers
Rules ¶
Checks that the order of modifiers. [Reference] ¶
Checks that the order of modifiers conforms to the suggestions in the Java Language specification, § 8.1.1, 8.3.1, 8.4.3 and 9.4.
In additional, modifiers are checked to ensure all annotations are declared before all other modifiers.
Code is easier to read if everybody follows a standard. The correct order is:
1. public 2. protected 3. private 4. abstract 5. default 6. static 7. sealed 8. non-sealed 9. final 10. transient 11. volatile 12. synchronized 13. native 14. strictfp
check ModifierOrder for the original rule.
Checks for redundant modifiers. [Reference] ¶
The Java Language Specification strongly discourages the usage of public and abstract for method declarations in interface definitions as a matter of style.
The check validates:
- Interface and annotation definitions.
- Final modifier on methods of final and anonymous classes.
- Type declarations nested under interfaces that are declared as
publicorstatic. - Class constructors.
- Nested
enumdefinitions that are declared as static. recorddefinitions that are declared as final and nested record definitions that are declared as static.
check RedundantModifier for the original rule.