Findbugs Bug SE_BAD_FIELD on boolean field

为君一笑 提交于 2020-01-05 07:52:12

问题


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

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

private boolean logged = false;

The description of this bug says

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

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.

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


回答1:


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.).



来源:https://stackoverflow.com/questions/12089659/findbugs-bug-se-bad-field-on-boolean-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!