[英]FindBugs and annotations in Eclipse
I've tagged a method in my code with javax.annotation.CheckForNull
and use it, without checking for null
, in another place.我在我的代码中用
javax.annotation.CheckForNull
标记了一个方法并在另一个地方使用它,而不检查null
。 When I run this code through FindBugs in Eclipse (via the plugin), there is no warning though.当我通过 Eclipse(通过插件)中的 FindBugs 运行此代码时,虽然没有警告。
Assuming there should be a warning (if not, what's a good test case?), why is it not showing?假设应该有一个警告(如果没有,什么是好的测试用例?),为什么它没有显示?
It does show other warnings, not related to annotations.它确实显示了其他警告,与注释无关。
I think the answer you're looking for can be found in here: Findbugs using jsr305 annotations in eclipse is not finding bugs我认为您正在寻找的答案可以在这里找到: Findbugs using jsr305 annotations in eclipse is not found bugs
(try running findbugs outside of eclipse) (尝试在 Eclipse 之外运行 findbugs)
I just tested (Windows, Eclipse Helios, latest plugin) and it worked, warning of possible dereferencing of a null variable.我刚刚测试过(Windows,Eclipse Helios,最新插件)并且它有效,警告可能取消引用 null 变量。
Perhaps check if this warning is not deactivated in your settings.也许检查您的设置中是否未禁用此警告。
[EDIT] Tested with both javax.annotation.CheckForNull
and edu.umd.cs.findbugs.annotations.CheckForNull
, and both in the same class and in a class in a different package. [编辑] 使用
javax.annotation.CheckForNull
和edu.umd.cs.findbugs.annotations.CheckForNull
进行测试,并且都在相同的 class 和 class 中的不同 ZEFE68BD78E603AFC677
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.