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

编程知识 更新时间:2023-05-02 19:02:03

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://wwwblogs/TSHHENLIHAI/p/10460860.html

更多推荐

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

本文发布于:2023-04-28 04:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/ce939bc922f4c58ed631327098994aff.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   错误   FindBugs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 107600文章数
  • 27226阅读数
  • 0评论数