https://checkstyle.org/checks/misc/finalparameters.html#FinalParameters
/var/tmp $ javac BrokenFile.java
/var/tmp $ cat config.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="FinalParameters"/>
</module>
</module>
/var/tmp $ cat BrokenFile.java
final class OuterClass {
record Record(String name) {
}
interface BrokenInterface {
static void test(Object o) { // violation expected
}
private void test2(Object o) { // violation expected
if (o instanceof String s) { // violation expected
System.out.println("s");
} else if (o instanceof Record(String name)) { // violation expected
System.out.println(name);
}
}
}
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.26.1-all.jar -c config.xml BrokenFile.java
Starting audit...
Audit done.
There should be several violations, for parametrs of the static and private method inside BrokenInterface as well as an error for the pattern variable s in the first if check and the record variable name.
Suppression config is provided in case somebody does not like this new behavior #17366 (comment)
https://checkstyle.org/checks/misc/finalparameters.html#FinalParameters
There should be several violations, for parametrs of the static and private method inside
BrokenInterfaceas well as an error for the pattern variablesin the first if check and the record variablename.Suppression config is provided in case somebody does not like this new behavior #17366 (comment)