FindBugs插件--FindBugs中的错误分析

1.Boxing/unboxing to parse a primitive
A boxed primitive is created from a String, just to extract the unboxed primitive value. It is more efficient to just call the static parseXXX method.

装箱/解装箱以解析原语
从字符串中创建一个已装箱的原语,只是为了提取未装箱的原语值。只调用静态parseXXX方法更有效。

Integer.parseInt(s)和Integer.valueof(s)
Integer.parseInt(s)的作用就是把字符串s解析成有符号的int基本类型
Integer.valueOf(s)把字符串s解析成Integer对象类型,返回的integer 可以调用对象中的方法。

-----------------------------------------------------------------------------------------
2.Boxed value is unboxed and then immediately reboxed
A boxed value is unboxed and then immediately reboxed.

已装箱的值被解除装箱,然后立即重新装箱
已装箱的值被解除装箱,然后立即重新装箱。
-----------------------------------------------------------------------------------------
3.Nullcheck of value previously dereferenced
A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.

以前取消引用的值的Nullcheck
在这里检查一个值是否为空,但是这个值不能为空,因为它以前被解引用过,如果它为空,那么在前面的解引用中就会发生空指针异常。本质上,这段代码和前面的解引用在是否允许该值为null上存在分歧。要么检查是多余的,要么以前的取消引用是错误的。

转载于:https://www.cnblogs.com/TSHHENLIHAI/p/10460860.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值