Program: 9229
Project: 9229
Buggy source:
/** 
 * Calculate the SerialVersionUID for a class.
 */
public long getSUID(){
  try {
    Field[] fields=getFields();
    Method[] methods=getMethods();
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    DataOutputStream dos=new DataOutputStream(baos);
    dos.writeUTF(getClassName());
    int classmods=0;
    classmods|=(isPublic() ? Constants.ACC_PUBLIC : 0);
    classmods|=(isFinal() ? Constants.ACC_FINAL : 0);
    classmods|=(isInterface() ? Constants.ACC_INTERFACE : 0);
    if (isInterface() && isAbstract()) {
      if (methods.length > 0)       classmods|=Constants.ACC_ABSTRACT;
    }
    dos.writeInt(classmods);
    List list=new ArrayList();
    String[] names=getInterfaceNames();
    if (names != null) {
      Arrays.sort(names);
      for (int i=0; i < names.length; i++)       dos.writeUTF(names[i]);
    }
    list.clear();
    for (int i=0; i < fields.length; i++) {
      Field field=fields[i];
      if (!(field.isPrivate() && field.isStatic()) && !(field.isPrivate() && field.isTransient()))       list.add(field);
    }
    Collections.sort(list,new FieldComparator());
    int relevantFlags=Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED| Constants.ACC_STATIC| Constants.ACC_FINAL| Constants.ACC_VOLATILE| Constants.ACC_TRANSIENT;
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      Field f=(Field)iter.next();
      dos.writeUTF(f.getName());
      dos.writeInt(relevantFlags & f.getModifiers());
      dos.writeUTF(f.getType().getSignature());
    }
    list.clear();
    List ctors=new ArrayList();
    boolean hasClinit=false;
    for (int i=0; i < methods.length; i++) {
      Method m=methods[i];
      boolean couldBeInitializer=m.getName().charAt(0) == '<';
      if (couldBeInitializer && m.getName().equals("String_Node_Str")) {
        hasClinit=true;
      }
 else       if (couldBeInitializer && m.getName().equals("String_Node_Str")) {
        if (!m.isPrivate())         ctors.add(m);
      }
 else {
        if (!m.isPrivate())         list.add(m);
      }
    }
    Collections.sort(ctors,new ConstructorComparator());
    Collections.sort(list,new MethodComparator());
    if (hasClinit) {
      dos.writeUTF("String_Node_Str");
      dos.writeInt(Modifier.STATIC);
      dos.writeUTF("String_Node_Str");
    }
    relevantFlags=Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED| Constants.ACC_STATIC| Constants.ACC_FINAL| Constants.ACC_SYNCHRONIZED| Constants.ACC_NATIVE| Constants.ACC_ABSTRACT| Constants.ACC_STRICT;
    for (Iterator iter=ctors.iterator(); iter.hasNext(); ) {
      Method m=(Method)iter.next();
      dos.writeUTF(m.getName());
      dos.writeInt(relevantFlags & m.getModifiers());
      dos.writeUTF(m.getSignature().replace('/','.'));
    }
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      Method m=(Method)iter.next();
      dos.writeUTF(m.getName());
      dos.writeInt(relevantFlags & m.getModifiers());
      dos.writeUTF(m.getSignature().replace('/','.'));
    }
    dos.flush();
    dos.close();
    byte[] bs=baos.toByteArray();
    MessageDigest md=MessageDigest.getInstance("String_Node_Str");
    byte[] result=md.digest(bs);
    long suid=0L;
    int pos=result.length > 8 ? 7 : result.length - 1;
    while (pos >= 0) {
      suid=suid << 8 | ((long)result[pos--] & 0xff);
    }
    return suid;
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + getClassName());
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str" + getClassName() + "String_Node_Str"+ e.toString());
  }
}

Fixed version (ground truth):
/** 
 * Calculate the SerialVersionUID for a class.
 */
public long getSUID(){
  try {
    Field[] fields=getFields();
    Method[] methods=getMethods();
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    DataOutputStream dos=new DataOutputStream(baos);
    dos.writeUTF(getClassName());
    int classmods=0;
    classmods|=(isPublic() ? Constants.ACC_PUBLIC : 0);
    classmods|=(isFinal() ? Constants.ACC_FINAL : 0);
    classmods|=(isInterface() ? Constants.ACC_INTERFACE : 0);
    if (isAbstract()) {
      if (isInterface()) {
        if (methods.length > 0)         classmods|=Constants.ACC_ABSTRACT;
      }
 else {
        classmods|=Constants.ACC_ABSTRACT;
      }
    }
    dos.writeInt(classmods);
    List list=new ArrayList();
    String[] names=getInterfaceNames();
    if (names != null) {
      Arrays.sort(names);
      for (int i=0; i < names.length; i++)       dos.writeUTF(names[i]);
    }
    list.clear();
    for (int i=0; i < fields.length; i++) {
      Field field=fields[i];
      if (!(field.isPrivate() && field.isStatic()) && !(field.isPrivate() && field.isTransient()))       list.add(field);
    }
    Collections.sort(list,new FieldComparator());
    int relevantFlags=Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED| Constants.ACC_STATIC| Constants.ACC_FINAL| Constants.ACC_VOLATILE| Constants.ACC_TRANSIENT;
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      Field f=(Field)iter.next();
      dos.writeUTF(f.getName());
      dos.writeInt(relevantFlags & f.getModifiers());
      dos.writeUTF(f.getType().getSignature());
    }
    list.clear();
    List ctors=new ArrayList();
    boolean hasClinit=false;
    for (int i=0; i < methods.length; i++) {
      Method m=methods[i];
      boolean couldBeInitializer=m.getName().charAt(0) == '<';
      if (couldBeInitializer && m.getName().equals("String_Node_Str")) {
        hasClinit=true;
      }
 else       if (couldBeInitializer && m.getName().equals("String_Node_Str")) {
        if (!m.isPrivate())         ctors.add(m);
      }
 else {
        if (!m.isPrivate())         list.add(m);
      }
    }
    Collections.sort(ctors,new ConstructorComparator());
    Collections.sort(list,new MethodComparator());
    if (hasClinit) {
      dos.writeUTF("String_Node_Str");
      dos.writeInt(Modifier.STATIC);
      dos.writeUTF("String_Node_Str");
    }
    relevantFlags=Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED| Constants.ACC_STATIC| Constants.ACC_FINAL| Constants.ACC_SYNCHRONIZED| Constants.ACC_NATIVE| Constants.ACC_ABSTRACT| Constants.ACC_STRICT;
    for (Iterator iter=ctors.iterator(); iter.hasNext(); ) {
      Method m=(Method)iter.next();
      dos.writeUTF(m.getName());
      dos.writeInt(relevantFlags & m.getModifiers());
      dos.writeUTF(m.getSignature().replace('/','.'));
    }
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      Method m=(Method)iter.next();
      dos.writeUTF(m.getName());
      dos.writeInt(relevantFlags & m.getModifiers());
      dos.writeUTF(m.getSignature().replace('/','.'));
    }
    dos.flush();
    dos.close();
    byte[] bs=baos.toByteArray();
    MessageDigest md=MessageDigest.getInstance("String_Node_Str");
    byte[] result=md.digest(bs);
    long suid=0L;
    int pos=result.length > 8 ? 7 : result.length - 1;
    while (pos >= 0) {
      suid=suid << 8 | ((long)result[pos--] & 0xff);
    }
    return suid;
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + getClassName());
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str" + getClassName() + "String_Node_Str"+ e.toString());
  }
}