Looking at the list of annotations in FindBugs 2.0, I see that a lot of them have been deprecated.
Some of these (@CheckForNull
, @NonNull
, etc.) have been deprecated because they have equivalent JSR-305 annotations. Good to finally settle the dilemma about which set of annotations to use.
But some FindBugs-specific annotations, such as @DefaultAnnotation
and @DefaultAnnotationForFields
, have also been deprecated and I cannot find any explanation of what to use in their place. I'm trying to migrate a codebase that makes heavy use of these annotations, and I'm a bit stuck.
I see that JSR-305 has @ParametersAreNonnullByDefault
, which I could use to replace some instances of @DefaultAnnotationForParameters
, but that will not cover all cases.
Am I missing something big here? Should I be using some kind of settings file or something, instead of annotations?
(note: see a related article at Should annotations in jar305.jar be preferred over similar annotations in annotation.jar for FindBugs? )
From the author's PDF (here), on page 51:
JSR-305 will only define
ParametersAreNonnullByDefault
, but more can be defined outside of JSR-305• and can be interpreted by static analyzers that interpret JSR-305 annotations
...so basically you can define it yourself, and give it the same name as the one you're replacing, and it should end up working fine since FindBugs only runs annotations by name (and likely prefers the JSR-305 annotations, maybe due to the deprecation in particular).
For an example, here is the source of @ParametersAreNonnullByDefault
.
For more information, you might need to email the author of JSR-305 and FindBugs: Bill Pugh (here is his website). Also, the issue has been added to the Sourceforge bug tracker (here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With