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
False positive for MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR in final class? #1812
Comments
Thanks for opening your first issue here! 😃 |
Looking at the implementation of this check, there's no need for inheritance to trigger this false positive. Calling any method in a final class from the constructor yields |
MC_OVERRIDABLE_METHOD_CALL errors should not be emitted for final final classes. spotbugs#1812
* fix MC_OVERRIDABLE_METHOD_CALL false positive for final class MC_OVERRIDABLE_METHOD_CALL errors should not be emitted for final final classes. #1812 * add changelog entry Co-authored-by: Kengo TODA <skypencil+github@gmail.com>
closed by #1813 |
Spotbugs 4.5.0 yields a warning for
MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR
when calling an inherited method from the constructor in a final class. But the method cannot be overridden by a subclass when the class is final.See repro: https://github.com/danielnorberg/spotbugs-falsepositives/blob/main/src/main/java/Repro_FalsePositive_MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR.java
I propose that spotbug should not yield
MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR
when the class is final, same as when the called method itself is final.The text was updated successfully, but these errors were encountered: