Checker reporting an ERROR affects EFFECTIVELY_FINAL symbol flag in subsequent source files #4595
Description
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 byUnusedVariable
, the symbol flags are different in subsequent files and theEFFECTIVELY_FINAL
flag is no longer set and soFormatStringAnnotation
is reporting "phantom violations" - the symbol flags stay the same when
UnusedVariable
is set toWARN
- 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
withUnusedVariable
to show its not related toDefaultLocale
/String.format
having any shared state withFormatStringAnnotation
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.
Activity