Closed
Description
What is the smallest, simplest way to reproduce the problem?
From checkstyle/checkstyle#3323
public class TestClass {
public void somePublicMethod() {
try (FileOutputStream out = new FileOutputStream("......")) {
//...
}
}
}
What did you expect to see?
public class TestClass {
public void somePublicMethod() {
try (FileOutputStream out = new FileOutputStream("......")) {
//...
}
}
}
What did you see instead?
public class TestClass {
public void somePublicMethod() {
try (final FileOutputStream out = new FileOutputStream("......")) {
//...
}
}
}
This is an interesting one as Checkstyle will flag this as a redundant modifier via checkstyle/checkstyle#3323 RedundantModifier
. The JLS spec has try/with resources variables implicitly final as per https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.3
You can see the implementation here https://github.com/checkstyle/checkstyle/blob/888a78f904ea173a4d5e71825aa63c3f35130376/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java#L211
Are you interested in contributing a fix to OpenRewrite?
Metadata
Metadata
Assignees
Type
Projects
Status
Done