findbug中可能的空指针取消引用是什么意思? [英] What is the meaning of Possible null pointer dereference in findbug?

查看:176
本文介绍了findbug中可能的空指针取消引用是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sonar,为了使我的代码更安全,我收到了这种违规行为:

I am using Sonar and I have got this kind of violation from it for a peace of my code:

 Correctness - Possible null pointer dereference  

有人在findbugs中了解此规则吗?我进行了很多搜索,但找不到描述此规则的很好的示例代码(Java),不幸的是,findbugs网站没有关于此规则的任何示例代码或很好的描述.

Has anyone know about this rule in findbugs? I searched a lot but I can not find a good sample code (in Java) which describe this rule, unfortunately findbugs site did not have any sample code or good description about this rule.

为什么会出现这种违规行为?

Why does this violation appear?

推荐答案

它在此处

NP: Possible null pointer dereference (NP_NULL_ON_SOME_PATH)

有一个语句分支,如果执行该语句,则保证将取消引用空值,这将在执行代码时生成NullPointerException.当然,问题可能出在分支或语句不可行,并且永远不会执行空指针异常.认为这超出了FindBugs的能力.

如果您将发布一些代码,则将更易于回答.

If you would have posted some code it would be easier to answer.

编辑,我看不到很多文档,但这是一个

EDIT I don't see a lot of documentation but here is one example! Hope this helps!

这篇关于findbug中可能的空指针取消引用是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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