简体   繁体   中英

Java Serializable object contains non-Serializable fields

I use FindBugs in eclipse, and there are tons of "troubling" warnings.
Here is the sketch code:

public class SerializableObject implements Serializable {

  private NonSerializableObject nso;

  .. setter, getter, everything else

}

Can this cause troubles? Or can we just ignore it? Or should we do the Serialization everywhere it touches?

It is in a JSF Web project.

You have to mark them as transient

When you declare a field transient it will be ignored during the serialization and deserialization process. Keep in mind that when you deserialize an object with a transient field that field's value will always be it's default (usually null.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM