Program: 59966
Project: 59966
Buggy source:
/** 
 * Read a class dump record. The class definition should already have been created from a LOAD_CLASS record.
 * @param loadedClasses Map of class ids and loaded classes. The class dump being read must be in this map
 */
public ClassDefinition readClassDumpRecord(Map<Integer,ClassDefinition> loadedClasses) throws IOException {
  int objectId=readInt(in);
  ClassDefinition cls=loadedClasses.get(objectId);
  if (cls == null) {
    throw new IllegalStateException("String_Node_Str" + objectId);
  }
  cls.setObjectId(objectId);
  cls.setStackTraceSerial(readInt(in));
  cls.setSuperClassObjectId(readInt(in));
  cls.setClassLoaderObjectId(readInt(in));
  cls.setSignersObjectId(readInt(in));
  cls.setProtectionDomainObjectId(readInt(in));
  in.skip(8);
  cls.setInstanceSize(readInt(in));
  short constantCount=readShort(in);
  List<ConstantField> constantFields=constantCount > 0 ? new ArrayList<ConstantField>() : null;
  cls.setConstantFields(constantFields);
  for (int i=0; i < constantCount; i++) {
    short poolIndex=readShort(in);
    BasicType type=BasicType.fromType(readByte(in));
    byte[] value=read(in,type.size);
    constantFields.add(new ConstantField(poolIndex,type,value));
  }
  short staticCount=readShort(in);
  ArrayList<StaticField> staticFields=staticCount > 0 ? new ArrayList<StaticField>() : null;
  cls.setStaticFields(staticFields);
  for (int i=0; i < staticCount; i++) {
    int nameId=readInt(in);
    BasicType type=BasicType.fromType(readByte(in));
    byte[] value=read(in,type.size);
    staticFields.add(new StaticField(type,value,nameId));
  }
  short fieldCount=readShort(in);
  ArrayList<InstanceField> instanceFields=fieldCount > 0 ? new ArrayList<InstanceField>() : null;
  cls.setInstanceFields(instanceFields);
  for (int i=0; i < fieldCount; i++) {
    int nameId=readInt(in);
    BasicType type=BasicType.fromType(readByte(in));
    instanceFields.add(new InstanceField(type,nameId));
  }
  return cls;
}

Fixed version (ground truth):
/** 
 * Read a class dump record. The class definition should already have been created from a LOAD_CLASS record.
 * @param loadedClasses Map of class ids and loaded classes. The class dump being read must be in this map
 */
public ClassDefinition readClassDumpRecord(Map<Integer,ClassDefinition> loadedClasses) throws IOException {
  int objectId=readInt(in);
  ClassDefinition cls=loadedClasses.get(objectId);
  if (cls == null) {
    throw new IllegalStateException("String_Node_Str" + objectId);
  }
  cls.setObjectId(objectId);
  cls.setStackTraceSerial(readInt(in));
  cls.setSuperClassObjectId(readInt(in));
  cls.setClassLoaderObjectId(readInt(in));
  cls.setSignersObjectId(readInt(in));
  cls.setProtectionDomainObjectId(readInt(in));
  skip(in,8);
  cls.setInstanceSize(readInt(in));
  short constantCount=readShort(in);
  if (constantCount > 0) {
    List<ConstantField> constantFields=new ArrayList<ConstantField>();
    cls.setConstantFields(constantFields);
    for (int i=0; i < constantCount; i++) {
      short poolIndex=readShort(in);
      BasicType type=BasicType.fromType(readByte(in));
      byte[] value=read(in,type.size);
      constantFields.add(new ConstantField(poolIndex,type,value));
    }
  }
  short staticCount=readShort(in);
  if (staticCount > 0) {
    ArrayList<StaticField> staticFields=new ArrayList<StaticField>();
    cls.setStaticFields(staticFields);
    for (int i=0; i < staticCount; i++) {
      int nameId=readInt(in);
      BasicType type=BasicType.fromType(readByte(in));
      byte[] value=read(in,type.size);
      staticFields.add(new StaticField(type,value,nameId));
    }
  }
  short fieldCount=readShort(in);
  if (fieldCount > 0) {
    ArrayList<InstanceField> instanceFields=new ArrayList<InstanceField>();
    cls.setInstanceFields(instanceFields);
    for (int i=0; i < fieldCount; i++) {
      int nameId=readInt(in);
      BasicType type=BasicType.fromType(readByte(in));
      instanceFields.add(new InstanceField(type,nameId));
    }
  }
  return cls;
}