Program: 73178
Project: 73178
Buggy source:
/** 
 * Check that clone(Workspace) method properly sets the fields. In a cloned Director, Attribute or Actor, all private fields should either point to null or to distinct objects.
 * @param namedObj The NamedObj, usually a Director, Attributeor actor to be checked.
 * @param namedObjClone the clone of the namedObj, created withclone(new Workspace())
 * @param field The field to be checked.
 * @return A string containing an error message if there is a problem,otherwise return the empty string.
 * @exception CloneNotSupportedException If namedObj does not supportclone(Workspace).
 * @exception IllegalAccessException If there is a problem gettinga field.
 * @exception ClassNotFoundException If a class cannot be found.
 */
private static String _checkCloneField(NamedObj namedObj,NamedObj namedObjClone,Field field) throws CloneNotSupportedException, IllegalAccessException, ClassNotFoundException {
  Class namedObjClass=namedObj.getClass();
  StringBuffer results=new StringBuffer();
  field.setAccessible(true);
  Class fieldType=field.getType();
  if (!fieldType.isPrimitive() && field.get(namedObj) != null && !Modifier.isStatic(field.getModifiers()) && !fieldType.toString().equals("String_Node_Str") && !field.getName().equals("String_Node_Str") && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !fieldType.equals(java.net.InetAddress.class) && !fieldType.equals(java.util.regex.Pattern.class) && !fieldType.equals(Boolean.class) && !fieldType.equals(Class.class) && !fieldType.equals(String.class) && !fieldType.equals(Token.class) && !fieldType.equals(ptolemy.data.type.Type.class) && !fieldType.equals(Settable.Visibility.class)) {
    if ((field.get(namedObj)).equals(field.get(namedObjClone)) && (System.identityHashCode(field.get(namedObj)) == System.identityHashCode(field.get(namedObjClone)))) {
      String message="String_Node_Str";
      if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        NamedObj fieldNamedObj=(NamedObj)Class.forName("String_Node_Str").cast(field.get(namedObj));
        NamedObj cloneNamedObj=(NamedObj)Class.forName("String_Node_Str").cast(field.get(namedObjClone));
        message="String_Node_Str" + fieldNamedObj.workspace().getName() + "String_Node_Str"+ cloneNamedObj.workspace().getName();
      }
      String assignment=field.getName();
      if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        assignment="String_Node_Str" + assignment + "String_Node_Str";
      }
 else       if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        Attribute fieldAttribute=(Attribute)field.get(namedObjClone);
        if (fieldAttribute.getContainer() != namedObjClone) {
          assignment="String_Node_Str" + fieldAttribute.getContainer().getName() + "String_Node_Str"+ fieldAttribute.getName()+ "String_Node_Str";
        }
 else {
          assignment="String_Node_Str" + assignment + "String_Node_Str";
        }
      }
 else {
        assignment="String_Node_Str" + "String_Node_Str" + assignment;
      }
      String shortClassName=field.getType().getName().substring(field.getType().getName().lastIndexOf("String_Node_Str") + 1);
      results.append("String_Node_Str" + field.getName() + "String_Node_Str"+ field.getType().getName()+ "String_Node_Str"+ "String_Node_Str"+ namedObjClass.getName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ field.getName()+ "String_Node_Str"+ shortClassName+ "String_Node_Str"+ assignment+ "String_Node_Str"+ message);
    }
  }
  return results.toString();
}

Fixed version (ground truth):
/** 
 * Check that clone(Workspace) method properly sets the fields. In a cloned Director, Attribute or Actor, all private fields should either point to null or to distinct objects.
 * @param namedObj The NamedObj, usually a Director, Attributeor actor to be checked.
 * @param namedObjClone the clone of the namedObj, created withclone(new Workspace())
 * @param field The field to be checked.
 * @return A string containing an error message if there is a problem,otherwise return the empty string.
 * @exception CloneNotSupportedException If namedObj does not supportclone(Workspace).
 * @exception IllegalAccessException If there is a problem gettinga field.
 * @exception ClassNotFoundException If a class cannot be found.
 */
private static String _checkCloneField(NamedObj namedObj,NamedObj namedObjClone,Field field) throws CloneNotSupportedException, IllegalAccessException, ClassNotFoundException {
  Class namedObjClass=namedObj.getClass();
  StringBuffer results=new StringBuffer();
  field.setAccessible(true);
  Class fieldType=field.getType();
  if (!fieldType.isPrimitive() && field.get(namedObj) != null && !Modifier.isStatic(field.getModifiers()) && !Modifier.isStatic(fieldType.getModifiers()) && !fieldType.toString().equals("String_Node_Str") && !field.getName().equals("String_Node_Str") && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !(field.getName().indexOf("String_Node_Str") != -1) && !fieldType.equals(java.net.InetAddress.class) && !fieldType.equals(java.util.regex.Pattern.class) && !fieldType.equals(Boolean.class) && !fieldType.equals(Class.class) && !fieldType.equals(String.class) && !fieldType.equals(Token.class) && !fieldType.equals(ptolemy.data.type.Type.class) && !fieldType.equals(Settable.Visibility.class)) {
    if ((field.get(namedObj)).equals(field.get(namedObjClone)) && (System.identityHashCode(field.get(namedObj)) == System.identityHashCode(field.get(namedObjClone)))) {
      String message="String_Node_Str";
      if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        NamedObj fieldNamedObj=(NamedObj)Class.forName("String_Node_Str").cast(field.get(namedObj));
        NamedObj cloneNamedObj=(NamedObj)Class.forName("String_Node_Str").cast(field.get(namedObjClone));
        message="String_Node_Str" + fieldNamedObj.workspace().getName() + "String_Node_Str"+ cloneNamedObj.workspace().getName();
      }
      String assignment=field.getName();
      if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        assignment="String_Node_Str" + assignment + "String_Node_Str";
      }
 else       if (Class.forName("String_Node_Str").isAssignableFrom(fieldType)) {
        Attribute fieldAttribute=(Attribute)field.get(namedObjClone);
        if (fieldAttribute.getContainer() != namedObjClone) {
          assignment="String_Node_Str" + fieldAttribute.getContainer().getName() + "String_Node_Str"+ fieldAttribute.getName()+ "String_Node_Str";
        }
 else {
          assignment="String_Node_Str" + assignment + "String_Node_Str";
        }
      }
 else {
        assignment="String_Node_Str" + "String_Node_Str" + assignment;
      }
      String shortClassName=field.getType().getName().substring(field.getType().getName().lastIndexOf("String_Node_Str") + 1);
      results.append("String_Node_Str" + field.getName() + "String_Node_Str"+ field.getType().getName()+ "String_Node_Str"+ "String_Node_Str"+ namedObjClass.getName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ field.getName()+ "String_Node_Str"+ shortClassName+ "String_Node_Str"+ assignment+ "String_Node_Str"+ message);
    }
  }
  return results.toString();
}