Program: 77489
Project: 77489
Buggy source:
/** 
 * This default implementation of the <code>initialize</code> method assumes all state held in objects of this type is exposed via the matching pairs of "setter" and "getter" methods in the order they are returned by the Introspector. If a property descriptor defines a "transient" attribute with a value equal to <code>Boolean.TRUE</code> the property is ignored by this default implementation. Note that this use of the word "transient" is quite independent of the field modifier that is used by the <code>ObjectOutputStream</code>. <p> For each non-transient property, an expression is created in which the nullary "getter" method is applied to the <code>oldInstance</code>. The value of this expression is the value of the property in the instance that is being serialized. If the value of this expression in the cloned environment <code>mutatesTo</code> the target value, the new value is initialized to make it equivalent to the old value. In this case, because the property value has not changed there is no need to call the corresponding "setter" method and no statement is emitted. If not however, the expression for this value is replaced with another expression (normally a constructor) and the corresponding "setter" method is called to install the new property value in the object. This scheme removes default information from the output produced by streams using this delegate. <p> In passing these statements to the output stream, where they will be executed, side effects are made to the <code>newInstance</code>. In most cases this allows the problem of properties whose values depend on each other to actually help the serialization process by making the number of statements that need to be written to the output smaller. In general, the problem of handling interdependent properties is reduced to that of finding an order for the properties in a class such that no property value depends on the value of a subsequent property.
 * @param oldInstance The instance to be copied.
 * @param newInstance The instance that is to be modified.
 * @param out The stream to which any initialization statements should be written.
 * @throws NullPointerException if {@code out} is {@code null}
 * @see java.beans.Introspector#getBeanInfo
 * @see java.beans.PropertyDescriptor
 */
protected void initialize(Class<?> type,Object oldInstance,Object newInstance,Encoder out){
  super.initialize(type,oldInstance,newInstance,out);
  if (oldInstance.getClass() == type) {
    initBean(type,oldInstance,newInstance,out);
  }
}

Fixed version (ground truth):
/** 
 * This default implementation of the <code>initialize</code> method assumes all state held in objects of this type is exposed via the matching pairs of "setter" and "getter" methods in the order they are returned by the Introspector. If a property descriptor defines a "transient" attribute with a value equal to <code>Boolean.TRUE</code> the property is ignored by this default implementation. Note that this use of the word "transient" is quite independent of the field modifier that is used by the <code>ObjectOutputStream</code>. <p> For each non-transient property, an expression is created in which the nullary "getter" method is applied to the <code>oldInstance</code>. The value of this expression is the value of the property in the instance that is being serialized. If the value of this expression in the cloned environment <code>mutatesTo</code> the target value, the new value is initialized to make it equivalent to the old value. In this case, because the property value has not changed there is no need to call the corresponding "setter" method and no statement is emitted. If not however, the expression for this value is replaced with another expression (normally a constructor) and the corresponding "setter" method is called to install the new property value in the object. This scheme removes default information from the output produced by streams using this delegate. <p> In passing these statements to the output stream, where they will be executed, side effects are made to the <code>newInstance</code>. In most cases this allows the problem of properties whose values depend on each other to actually help the serialization process by making the number of statements that need to be written to the output smaller. In general, the problem of handling interdependent properties is reduced to that of finding an order for the properties in a class such that no property value depends on the value of a subsequent property.
 * @param type the type of the instances
 * @param oldInstance The instance to be copied.
 * @param newInstance The instance that is to be modified.
 * @param out The stream to which any initialization statements should be written.
 * @throws NullPointerException if {@code out} is {@code null}
 * @see java.beans.Introspector#getBeanInfo
 * @see java.beans.PropertyDescriptor
 */
protected void initialize(Class<?> type,Object oldInstance,Object newInstance,Encoder out){
  super.initialize(type,oldInstance,newInstance,out);
  if (oldInstance.getClass() == type) {
    initBean(type,oldInstance,newInstance,out);
  }
}