布尔字段上的Findbugs错误SE_BAD_FIELD [英] Findbugs Bug SE_BAD_FIELD on boolean field

查看:719
本文介绍了布尔字段上的Findbugs错误SE_BAD_FIELD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将Findbugs配置为通过Maven在我们的Jenkins上运行.

We have Findbugs configured to run on our Jenkins via Maven.

在以下代码行中,它还抱怨SE_BAD_FIELD:

Among other things it complains about SE_BAD_FIELD on the following code line:

private boolean logged = false;

对该错误的描述

Se:可序列化的非瞬态不可序列化实例字段 类(SE_BAD_FIELD)

Se: Non-transient non-serializable instance field in serializable class (SE_BAD_FIELD)

此Serializable类定义一个非原始实例字段,该字段 既不是临时的,可序列化的也不是java.lang.Object,并且不是 似乎实现了Externalizable接口或readObject() 和writeObject()方法.此类的对象将不会 如果此对象中存储了不可序列化的对象,则可以正确地反序列化 字段.

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.

但是boolean是原始的!那么为什么要抱怨呢?还是这种Findbugs,Maven或Jenkins Bug?

But boolean is a primitive!? So why is it complaining? Or is this some kind of Findbugs, Maven or Jenkins Bug?

推荐答案

我注意到,FindBugs有时会报告SE_BAD_FIELD的行号错误.因此,您可能需要检查其他字段的可串行性. (我使用FB 1.3.9.).

I have noticed that FindBugs sometimes reports the wrong line number for SE_BAD_FIELD. So you might want to check the other fields for serializability instead. (I use FB 1.3.9.).

这篇关于布尔字段上的Findbugs错误SE_BAD_FIELD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆