-
Notifications
You must be signed in to change notification settings - Fork 578
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
@ParametersAreNonnullByDefault ignored for private methods if set on package or class level. #374
Comments
Hi @adimaret, |
@KengoTODA |
@KengoTODA Unfortunately the bug has not been fixed yet. I updated my example project to spotbugs 3.1.3 but still the bug is only reported for TestNonnullByDefaultFromMethodAnnotation.java |
This doesn't seem to fixed yet. |
Remove the restriction that a method must not be private in order to inherit default annotations from package or class scope. Resolves spotbugs#374.
I tracked down the failure to what appears to be an intentional choice to omit private methods (code ref), but nonetheless I went ahead and opened a PR. Happy to keep discussion here if that was premature on my part. |
…class scope (#1222) * refs #374: reproduce reported problem * allow private methods to inherit default annotations Remove the restriction that a method must not be private in order to inherit default annotations from package or class scope. Resolves #374. * bump year in license header * add a comment in changelog as per the PR template * ./gradlew spotlessApply * address pr comments - fix copyright attribution - move entry in changelog Co-authored-by: Ritee <chenh0510@qq.com>
We have a problem here where spotbugs does not apply the "@ParametersAreNonnullByDefault" annotation to private methods if the annotation has been set on package or class level. If you annotate the private method directly however it works.
How to reproduce:
Expected Behavior:
Spotbugs should find the same bug in all three example classes, as all classes have the same code, but simply get their @ParametersAreNonnullByDefault annotation from a different level (package/class/method).
Actual Behavior:
Spotbugs only finds the bug in "TestNonnullByDefaultFromMethodAnnotation.java"
Workaround:
Change all private methods to protected or public and spotbugs will correctly complain about all three classes.
spotbugs.zip
The text was updated successfully, but these errors were encountered: