findbugs 错误分析

 

findbugs 出错类型及对应解释
1、Dead store to local variable 本地变量存储了闲置不用的对象
举例:
List accountCoList = new ArrayList();
我们为accountCoList新建了一个对象,但是程序的后面并没有使用这个这个新建对象。
建议改为:
List accountCoList = null;

2、Write to static field from instance method 向static字段中写入值
举例:
 private static DBRBO dbrBO;
 public final void refresh() {
        danskeBankBO = null;
        dbrBO = null;
        fileAndPathBO = null;
    }
建议改为:
去掉static。
3、Load of known null value 大体意思是加载了null的对象。
举例
        if (null == boList) {

            for (int i = 0; i < boList.size(); i++) {
                entityList.add(productBOToEntity(boList.get(i)));
            }
        }
4、Exception is caught when Exception is not thrown 这个意思比较好理解:就是catch了异常但是try里并没有抛出异常
5、Method ignores exceptional return value 没有对方法的异常返回值进行检查
6、Comparison of String objects using == or !=
This code compares java.lang.String objects for reference equality using the == or != operators.
Unless both strings are either constants in a source file, or have been interned using the String.intern() method,
 the same string value may be represented by two different String objects. Consider using the equals(Object) method
  instead.
  从字面意思可以理解String对象进行比较的时候:只有两种情况可以使用== or !=的,这两种情况是;在源文件中是个常数或者是调用
  String.intern()方法,使用String的规范化表示形式来进行比较,如果不是这两中情况的话推荐使用.equals(object)方式
7、Method names should start with a lower case letter 这个好理解方法名的第一个字母不能是大写
8、Non-transient non-serializable instance field in serializable class
This Serializable class defines a non-primitive instance field which is neither transient, Serializable,
 or java.lang.Object, and does not appear to implement the Externalizable interface or the readObject()
  and writeObject() methods.? Objects of this class will not be deserialized correctly if a non-Serializable object
   is stored in this field.
这个错误的意思是:在可序列化的类中存在不能序列化或者不能暂存的数据

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值