Instances of a ``++Serializable++`` class can be saved out to file and rehydrated at leisure. But that only works when all the values in the class instance are themselves ``++Serializable++`` (or ``++transient++``). Storing a non-serializable value in a ``++Serializable++`` class will prevent the serialization of that class. 


== Noncompliant Code Example

----
interface Fruit extends Serializable {...} 
class Gooseberry implements Fruit { // Nonserializable because of Thread field 
  Thread thread; 
} 

class Bowl implements Serializable { 
  private static final long serialVersionUID = 1; 

  private Fruit fruit = new Gooseberry(); //Non-Compliant 
} 
----


== Compliant Solution

----
interface Fruit implements Serializable {...} 
class Gooseberry implements Fruit {...} //Serializable 

class Bowl implements Serializable { 
  private static final long serialVersionUID = 1; 

  private Fruit fruit = new Gooseberry(); //Compliant, Gooseberry is serializable 
} 
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
