FindBugs 2.0 中已弃用的注释 [英] Deprecated annotations in FindBugs 2.0

查看:21
本文介绍了FindBugs 2.0 中已弃用的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看 FindBugs 中的注释列表2.0,我看到其中很多已被弃用.

Looking at the list of annotations in FindBugs 2.0, I see that a lot of them have been deprecated.

其中一些(@CheckForNull@NonNull 等)已被弃用,因为它们具有等效的 JSR-305 注释.很高兴最终解决了使用哪组注释的困境.

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.

但是一些特定于 FindBugs 的注释,例如 @DefaultAnnotation@DefaultAnnotationForFields,也已被弃用,我找不到任何关于在它们的位置使用什么的解释.我正在尝试迁移大量使用这些注释的代码库,但我有点卡住了.

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.

我看到 JSR-305 有 @ParametersAreNonnullByDefault,我可以用它来替换 @DefaultAnnotationForParameters 的一些实例,但这不会涵盖所有情况.

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?

推荐答案

(注意:请参阅 对于 FindBugs 来说,jar305.jar 中的注释应该优先于 annotation.jar 中的类似注释吗?)

来自作者的 PDF(此处),第51:

From the author's PDF (here), on page 51:

JSR-305 只会定义 ParametersAreNonnullByDefault,但可以在 JSR-305 之外定义更多

JSR-305 will only define ParametersAreNonnullByDefault, but more can be defined outside of JSR-305

• 并且可以被静态分析器解释解释 JSR-305 注释

• and can be interpreted by static analyzers that interpret JSR-305 annotations

...所以基本上你可以自己定义它,并给它取与你要替换的名称相同的名称,它应该可以正常工作,因为 FindBugs 只按名称运行注释(并且可能更喜欢 JSR-305注释,可能特别是由于弃用).

...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).

例如,这里@ParametersAreNonnullByDefault的来源.

有关更多信息,您可能需要通过电子邮件发送给 JSR-305 和 FindBugs 的作者:Bill Pugh (这里是他的网站).此外,该问题已添加到 Sourceforge 错误跟踪器 (这里).

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).

这篇关于FindBugs 2.0 中已弃用的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆