diff --git a/src/main/java/org/openrewrite/staticanalysis/FinalizePrivateFields.java b/src/main/java/org/openrewrite/staticanalysis/FinalizePrivateFields.java index d378e532c..dab6427d5 100644 --- a/src/main/java/org/openrewrite/staticanalysis/FinalizePrivateFields.java +++ b/src/main/java/org/openrewrite/staticanalysis/FinalizePrivateFields.java @@ -136,7 +136,7 @@ private List collectPrivateFields(Cursor c .map(J.VariableDeclarations.class::cast) .filter(mv -> mv.hasModifier(J.Modifier.Type.Private) && !mv.hasModifier(J.Modifier.Type.Final) - && !(topLevel instanceof Cs || mv.getModifiers().stream().noneMatch(m -> "readonly".equals(m.getKeyword()))) + && (!(topLevel instanceof Cs) || mv.getModifiers().stream().noneMatch(m -> "readonly".equals(m.getKeyword()))) && !mv.hasModifier(J.Modifier.Type.Volatile)) .filter(mv -> !anyAnnotationApplied(new Cursor(bodyCursor, mv))) .map(J.VariableDeclarations::getVariables)