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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM