admin管理员组

文章数量:1530518

BX_BOXING_IMMEDIATELY_UNBOXED

Primitive value is boxed and then immediately unboxed

对原始值进行装箱,然后立即取消装箱。这可能是在一个未要求装箱的地方进行了手动装箱,从而迫使编译器进行立即撤消装箱的操作

BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION

Primitive value is boxed then unboxed to perform primitive coercion

对原始值进行装箱然后立即把它强制转换为另外一种原始类型。例如:

new Double(d).intValue()应该直接进行强制转换例如:(int) d

DM_BOXED_PRIMITIVE_TOSTRING

Method allocates a boxed primitive just to call toString

仅仅为了调用封装类的toString()而对原始类型进行封装操作。比这种方法更有效的是调用封装类的toString(…)方法例如:

new Integer(1).toString() 替换为 Integer.toString(1)

new Long(1).toString() 替换为 Long.toString(1)

new Float(1.0).toString() 替换为 Float.toString(1.0)

new Double(1.0).toString() 替换为 Double.toString(1.0)

new Byte(1).toString() 替换为 Byte.toString(1)

new Short(1).toString() 替换为 Short.toString(1)

new Boolea

本文标签: 规则自定义JavafindbugsPerformance