I was upgrading error-prone to 2.31.0 on a branch for a project and it started reporting both DefaultCharset and FormatStringAnnotation violations in a module.
The former were expected and valid but the latter left me scratching my head as the FormatStringAnnotation checker was not modified between the versions afaict.
I tried reproducing the FormatStringAnnotation violations in an error-prone unit test but the code was passing the check just fine.
Then I tried to reproduce the whole scenario in an error-prone integration test and was successful, so I have pushed the test code here:
XN137#1
note:
- it looks like after an
ERROR has been reported by UnusedVariable, the symbol flags are different in subsequent files and the EFFECTIVELY_FINAL flag is no longer set and so FormatStringAnnotation is reporting "phantom violations"
- the symbol flags stay the same when
UnusedVariable is set to WARN
- the symbol flags stay the same when the file comes before the file that contains the
UnusedVariable ERROR violation
- in the IT I have replaced
DefaultCharset with UnusedVariable to show its not related to DefaultLocale / String.format having any shared state with FormatStringAnnotation
please take a look and let me know whether this is expected behavior in errorprone (or javac) or a potential bug?
If the former, maybe this should be documented somewhere as it can be really confusing if checker B starts reporting "unjustified" violations just because checker A has already reported an ERROR.
sorry in case i missed something obvious that would explain this behavior.
I was upgrading error-prone to 2.31.0 on a branch for a project and it started reporting both
DefaultCharsetandFormatStringAnnotationviolations in a module.The former were expected and valid but the latter left me scratching my head as the
FormatStringAnnotationchecker was not modified between the versions afaict.I tried reproducing the
FormatStringAnnotationviolations in an error-prone unit test but the code was passing the check just fine.Then I tried to reproduce the whole scenario in an error-prone integration test and was successful, so I have pushed the test code here:
XN137#1
note:
ERRORhas been reported byUnusedVariable, the symbol flags are different in subsequent files and theEFFECTIVELY_FINALflag is no longer set and soFormatStringAnnotationis reporting "phantom violations"UnusedVariableis set toWARNUnusedVariableERRORviolationDefaultCharsetwithUnusedVariableto show its not related toDefaultLocale/String.formathaving any shared state withFormatStringAnnotationplease take a look and let me know whether this is expected behavior in errorprone (or javac) or a potential bug?
If the former, maybe this should be documented somewhere as it can be really confusing if checker B starts reporting "unjustified" violations just because checker A has already reported an ERROR.
sorry in case i missed something obvious that would explain this behavior.