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上存在分歧。要么检查是多余的,要么以前的取消引用是错误的。

猜你喜欢

转载自www.cnblogs.com/TSHHENLIHAI/p/10460860.html