Program: 13691
Project: 13691
Buggy source:
/** 
 * Handle single VIM Data Object 
 */
private static Object fromXML(String type,Element node) throws Exception {
  Class<?> clazz=Class.forName(PACKAGE_NAME + "String_Node_Str" + type);
  Object obj=clazz.newInstance();
  List<?> subNodes=node.elements();
  for (int i=0; i < subNodes.size(); i++) {
    Element e=(Element)subNodes.get(i);
    String tagName=e.getName();
    Field field=null;
    if (tagName.equals("String_Node_Str") || tagName.equals("String_Node_Str") || tagName.equals("String_Node_Str")|| tagName.equals("String_Node_Str")|| tagName.equals("String_Node_Str")) {
      field=clazz.getField("String_Node_Str" + tagName);
    }
 else {
      field=clazz.getField(tagName);
    }
    Class<?> fType=field.getType();
    boolean isFieldArray=fType.isArray();
    String arrayTypeName=fType.getSimpleName();
    String xsiType=e.attributeValue(XSI_TYPE);
    if (xsiType != null && (!xsiType.startsWith("String_Node_Str"))) {
      fType=Class.forName(PACKAGE_NAME + "String_Node_Str" + xsiType);
    }
    String fTypeFullName=fType.getCanonicalName();
    String fTypeSimpleName=fType.getSimpleName();
    if (fTypeSimpleName.startsWith("String_Node_Str")) {
      if (isFieldArray) {
        List<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size();
        ManagedObjectReference[] mos=new ManagedObjectReference[al.size()];
        for (int j=0; j < mos.length; j++) {
          Element elem=(Element)al.get(j);
          mos[j]=XmlGen.createMOR(elem.attributeValue("String_Node_Str"),elem.getText());
        }
        field.set(obj,mos);
      }
 else {
        field.set(obj,createMOR(e.attributeValue("String_Node_Str"),e.getText()));
      }
    }
 else     if (fType.isEnum()) {
      String enumStr=e.getText();
      Class enumClass=Class.forName(fTypeFullName);
      Object fo=Enum.valueOf(enumClass,enumStr);
      field.set(obj,fo);
    }
 else     if (((xsiType != null) && (!xsiType.startsWith("String_Node_Str"))) || fTypeFullName.startsWith(PACKAGE_NAME)) {
      if (isFieldArray) {
        ArrayList<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size();
        arrayTypeName=arrayTypeName.substring(0,arrayTypeName.length() - 2);
        Object ao=Array.newInstance(Class.forName(PACKAGE_NAME + "String_Node_Str" + arrayTypeName),al.size());
        for (int j=0; j < al.size(); j++) {
          Element elem=(Element)al.get(j);
          String elemType=arrayTypeName;
          if (elem.attributeValue(XSI_TYPE) != null) {
            elemType=elem.attributeValue(XSI_TYPE);
          }
          Object o=fromXML(elemType,elem);
          Array.set(ao,j,o);
        }
        field.set(obj,ao);
      }
 else {
        Object o=null;
        if (xsiType != null) {
          o=fromXML(xsiType,e);
        }
 else {
          o=fromXML(fType.getSimpleName(),e);
        }
        field.set(obj,o);
      }
    }
 else {
      if (isFieldArray) {
        ArrayList<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size();
        String[] values=new String[al.size()];
        for (int j=0; j < values.length; j++) {
          values[j]=((Element)al.get(j)).getText();
        }
        String fTrueType=null;
        if (xsiType != null) {
          fTrueType=xsiType.substring("String_Node_Str".length()) + "String_Node_Str";
        }
 else {
          fTrueType=fTypeSimpleName;
          if (!fTrueType.endsWith("String_Node_Str")) {
            fTrueType=fTrueType + "String_Node_Str";
          }
        }
        setFieldValue(field,obj,fTrueType,values);
      }
 else {
        if (xsiType != null && xsiType.startsWith("String_Node_Str")) {
          xsiType=xsiType.substring("String_Node_Str".length());
          setFieldValue(field,obj,xsiType,new String[]{e.getText()});
        }
 else {
          setFieldValue(field,obj,xsiType,new String[]{e.getText()});
        }
      }
    }
  }
  return obj;
}

Fixed version (ground truth):
/** 
 * Handle single VIM Data Object 
 */
private static Object fromXML(String type,Element node) throws Exception {
  Class<?> clazz=Class.forName(PACKAGE_NAME + "String_Node_Str" + type);
  Object obj=clazz.newInstance();
  List<?> subNodes=node.elements();
  for (int i=0; i < subNodes.size(); i++) {
    Element e=(Element)subNodes.get(i);
    String tagName=e.getName();
    Field field=null;
    if (tagName.equals("String_Node_Str") || tagName.equals("String_Node_Str") || tagName.equals("String_Node_Str")|| tagName.equals("String_Node_Str")|| tagName.equals("String_Node_Str")) {
      field=clazz.getField("String_Node_Str" + tagName);
    }
 else {
      field=clazz.getField(tagName);
    }
    Class<?> fType=field.getType();
    boolean isFieldArray=fType.isArray();
    String arrayTypeName=fType.getSimpleName();
    String xsiType=e.attributeValue(XSI_TYPE);
    if (xsiType != null && (!xsiType.startsWith("String_Node_Str"))) {
      fType=Class.forName(PACKAGE_NAME + "String_Node_Str" + xsiType);
    }
    String fTypeFullName=fType.getCanonicalName();
    String fTypeSimpleName=fType.getSimpleName();
    if (fTypeSimpleName.startsWith("String_Node_Str")) {
      if (isFieldArray) {
        List<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size() - 1;
        ManagedObjectReference[] mos=new ManagedObjectReference[al.size()];
        for (int j=0; j < mos.length; j++) {
          Element elem=(Element)al.get(j);
          mos[j]=XmlGen.createMOR(elem.attributeValue("String_Node_Str"),elem.getText());
        }
        field.set(obj,mos);
      }
 else {
        field.set(obj,createMOR(e.attributeValue("String_Node_Str"),e.getText()));
      }
    }
 else     if (fType.isEnum()) {
      String enumStr=e.getText();
      Class enumClass=Class.forName(fTypeFullName);
      Object fo=Enum.valueOf(enumClass,enumStr);
      field.set(obj,fo);
    }
 else     if (((xsiType != null) && (!xsiType.startsWith("String_Node_Str"))) || fTypeFullName.startsWith(PACKAGE_NAME)) {
      if (isFieldArray) {
        ArrayList<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size() - 1;
        arrayTypeName=arrayTypeName.substring(0,arrayTypeName.length() - 2);
        Object ao=Array.newInstance(Class.forName(PACKAGE_NAME + "String_Node_Str" + arrayTypeName),al.size());
        for (int j=0; j < al.size(); j++) {
          Element elem=(Element)al.get(j);
          String elemType=arrayTypeName;
          if (elem.attributeValue(XSI_TYPE) != null) {
            elemType=elem.attributeValue(XSI_TYPE);
          }
          Object o=fromXML(elemType,elem);
          Array.set(ao,j,o);
        }
        field.set(obj,ao);
      }
 else {
        Object o=null;
        if (xsiType != null) {
          o=fromXML(xsiType,e);
        }
 else {
          o=fromXML(fType.getSimpleName(),e);
        }
        field.set(obj,o);
      }
    }
 else {
      if (isFieldArray) {
        ArrayList<?> al=getAllArrayElements(subNodes,tagName,i,subNodes.size());
        i=i + al.size() - 1;
        String[] values=new String[al.size()];
        for (int j=0; j < values.length; j++) {
          values[j]=((Element)al.get(j)).getText();
        }
        String fTrueType=null;
        if (xsiType != null) {
          fTrueType=xsiType.substring("String_Node_Str".length()) + "String_Node_Str";
        }
 else {
          fTrueType=fTypeSimpleName;
          if (!fTrueType.endsWith("String_Node_Str")) {
            fTrueType=fTrueType + "String_Node_Str";
          }
        }
        setFieldValue(field,obj,fTrueType,values);
      }
 else {
        if (xsiType != null && xsiType.startsWith("String_Node_Str")) {
          xsiType=xsiType.substring("String_Node_Str".length());
          setFieldValue(field,obj,xsiType,new String[]{e.getText()});
        }
 else {
          setFieldValue(field,obj,xsiType,new String[]{e.getText()});
        }
      }
    }
  }
  return obj;
}