FindBugs 2.0 中已弃用的注释
查看FindBugs 2.0 中的注释列表,我发现其中很多已被弃用。
其中一些(@CheckForNull
、@NonNull
等)已被弃用,因为它们具有等效的 JSR-305 注释。很高兴终于解决了使用哪组注释的困境。
但一些 FindBugs 特定的注释,例如 @DefaultAnnotation 和 @DefaultAnnotationForFields 也已被弃用,我找不到任何关于在其位置使用什么的解释。我正在尝试迁移大量使用这些注释的代码库,但我有点卡住了。
我看到 JSR-305 有 @ParametersAreNonnullByDefault
,我可以用它来替换 @DefaultAnnotationForParameters
的一些实例,但这并不能涵盖所有情况。
我在这里错过了一些大事吗?我应该使用某种设置文件或其他东西,而不是注释吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(注意:请参阅相关文章 对于 FindBugs,jar305.jar 中的注释是否应该优先于 comment.jar 中的类似注释? )
来自作者的 PDF (此处),第 51 页:
...所以基本上您可以自己定义它,并为其指定与要替换的名称相同的名称,并且它最终应该可以正常工作,因为 FindBugs 仅按名称运行注释(并且可能更喜欢JSR-305 注释,可能特别是由于弃用所致)。
例如,这里是
@ParametersAreNonnullByDefault
的来源。有关详细信息,您可能需要向 JSR-305 和 FindBugs 的作者发送电子邮件:Bill Pugh(此处 是他的网站)。此外,该问题已添加到 Sourceforge 错误跟踪器中 (
(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:
...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).