Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checker reporting an ERROR affects EFFECTIVELY_FINAL symbol flag in subsequent source files #4595

Open
XN137 opened this issue Sep 30, 2024 · 0 comments

Comments

@XN137
Copy link

XN137 commented Sep 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant