code: public void writeObject(Object oldInstance, Encoder out)
  	{
  		Object newInstance = out.get(oldInstance);
  		Class<?> clazz = oldInstance.getClass();
  		if (mutatesTo(oldInstance, newInstance))
  		{
  			initialize(clazz, oldInstance, newInstance, out);
  		}
  		else
  		{
  			out.remove(oldInstance);
  			out.writeExpression(instantiate(oldInstance, out));
  			newInstance = out.get(oldInstance);
  			if (newInstance != null)
  			{
  				initialize(clazz, oldInstance, newInstance, out);
  			}
  		}
  	}
docs: Writes a bean object to the given encoder. First it is checked whether the simulating new object can be mutated to the old instance. If yes, it is
  initialized to produce a series of expressions and statements that can be used to restore the old instance. Otherwise, remove the new object in the
  simulating new environment and writes an expression that can instantiate a new instance of the same type as the old one to the given encoder.
  
  @param oldInstance
  the old instance to be written
  @param out
  the encoder that the old instance will be written to