Program: 168725
Project: 168725
Buggy source:
public static final void forObj(final JSONWriter writer,Object obj) throws IOException {
  if (obj == null) {
    writer.writeNull();
  }
 else {
    if (obj instanceof String) {
      writer.writeString((String)obj);
    }
 else     if (obj instanceof Integer) {
      writer.writeInt((Integer)obj);
    }
 else     if (obj instanceof Long) {
      writer.writeLong((Long)obj);
    }
 else     if (obj instanceof Double) {
      writer.writeDouble((Double)obj);
    }
 else     if (obj instanceof Float) {
      writer.writeFloat((Float)obj);
    }
 else     if (obj instanceof ToJSONString) {
      ((ToJSONString)obj).toString(writer);
    }
 else     if (obj instanceof PersistentArrayMap) {
      PersistentArrayMap map=(PersistentArrayMap)obj;
      map.kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object key,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          writer.writeFieldName(key.toString());
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
    }
 else     if (obj instanceof PersistentHashMap) {
      PersistentHashMap map=(PersistentHashMap)obj;
      map.kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object key,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          writer.writeFieldName(key.toString());
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
    }
 else     if (obj instanceof PersistentVector) {
      ((PersistentVector)obj).kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object k,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
    }
 else     if (obj instanceof Map) {
      writer.startObj();
      int i=0;
      for (      Map.Entry<Object,Object> entry : ((Map<Object,Object>)obj).entrySet()) {
        if (i++ != 0)         writer.writeComma();
        writer.writeFieldName(entry.getKey().toString());
        forObj(writer,entry.getValue());
      }
      writer.endObj();
    }
 else     if (obj instanceof List) {
      List<Object> list=(List<Object>)obj;
      for (int i=0; i < list.size(); i++) {
        if (i != 0)         writer.writeComma();
        forObj(writer,list.get(i));
      }
    }
 else     if (obj instanceof Collection) {
      Iterator<Object> coll=((Collection<Object>)obj).iterator();
      int i=0;
      writer.startArr();
      while (coll.hasNext()) {
        if (i++ != 0)         writer.writeComma();
        forObj(writer,coll.next());
      }
      writer.endArr();
    }
  }
}

Fixed version (ground truth):
public static final void forObj(final JSONWriter writer,final Object obj) throws IOException {
  if (obj == null) {
    writer.writeNull();
  }
 else {
    if (obj instanceof String) {
      writer.writeString((String)obj);
    }
 else     if (obj instanceof Named) {
      writer.writeString(((Named)obj).getName());
    }
 else     if (obj instanceof Integer) {
      writer.writeInt((Integer)obj);
    }
 else     if (obj instanceof Long) {
      writer.writeLong((Long)obj);
    }
 else     if (obj instanceof Double) {
      writer.writeDouble((Double)obj);
    }
 else     if (obj instanceof Float) {
      writer.writeFloat((Float)obj);
    }
 else     if (obj instanceof ToJSONString) {
      ((ToJSONString)obj).toString(writer);
    }
 else     if (obj instanceof PersistentArrayMap) {
      writer.startObj();
      final PersistentArrayMap map=(PersistentArrayMap)obj;
      map.kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object key,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          writer.writeFieldName(convertFieldName(key));
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
      writer.endObj();
    }
 else     if (obj instanceof PersistentHashMap) {
      writer.startObj();
      final PersistentHashMap map=(PersistentHashMap)obj;
      map.kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object key,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          writer.writeFieldName(convertFieldName(key.toString()));
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
      writer.endObj();
    }
 else     if (obj instanceof PersistentVector) {
      writer.startArr();
      ((PersistentVector)obj).kvreduce(new AFn(){
        @Override public Object invoke(        Object state,        Object k,        Object val){
          if (((Counter)state).i++ != 0)           writer.writeComma();
          try {
            JSONGenerator.forObj(writer,val);
          }
 catch (          Exception e) {
            throw new RuntimeException(e);
          }
          return state;
        }
      }
,new Counter());
      writer.endArr();
    }
 else     if (obj instanceof Map) {
      writer.startObj();
      int i=0;
      for (      Map.Entry<Object,Object> entry : ((Map<Object,Object>)obj).entrySet()) {
        if (i++ != 0)         writer.writeComma();
        writer.writeFieldName(convertFieldName(entry.getKey()));
        forObj(writer,entry.getValue());
      }
      writer.endObj();
    }
 else     if (obj instanceof List) {
      final List<Object> list=(List<Object>)obj;
      writer.startArr();
      for (int i=0; i < list.size(); i++) {
        if (i != 0)         writer.writeComma();
        forObj(writer,list.get(i));
      }
      writer.endArr();
    }
 else     if (obj instanceof Iterable) {
      final Iterator<Object> coll=((Iterable<Object>)obj).iterator();
      int i=0;
      writer.startArr();
      while (coll.hasNext()) {
        if (i++ != 0)         writer.writeComma();
        forObj(writer,coll.next());
      }
      writer.endArr();
    }
 else {
      writer.writeString(cleanUnknownOutput(obj.toString()));
    }
  }
}