问题
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