Program: 17863
Project: 17863
Buggy source:
@Override public JsonType visitDeclared(DeclaredType declaredType,Void o){
  if (isJsonPrimitive(declaredType)) {
    return new JsonPrimitive(declaredType.toString());
  }
 else   if (isInstanceOf(declaredType,Collection.class)) {
    if (declaredType.getTypeArguments().size() == 0) {
      return new JsonArray(new JsonPrimitive(Object.class.getName()));
    }
 else {
      TypeParameterElement elem=((TypeElement)declaredType.asElement()).getTypeParameters().get(0);
      _typeRecursionDetector.add(_type.toString());
      return new JsonArray(acceptOrRecurse(o,elem.asType()));
    }
  }
 else   if (isInstanceOf(declaredType,Map.class)) {
    if (declaredType.getTypeArguments().size() == 0) {
      return new JsonDict(new JsonPrimitive(Object.class.getName()),new JsonPrimitive(Object.class.getName()));
    }
 else {
      TypeMirror key=declaredType.getTypeArguments().get(0);
      TypeMirror val=declaredType.getTypeArguments().get(1);
      _typeRecursionDetector.add(_type.toString());
      JsonType keyJson=acceptOrRecurse(o,key);
      JsonType valJson=acceptOrRecurse(o,val);
      return new JsonDict(keyJson,valJson);
    }
  }
 else {
    TypeElement element=(TypeElement)declaredType.asElement();
    if (element.getKind() == ElementKind.ENUM) {
      List<String> enumConstants=new ArrayList();
      for (      Element e : element.getEnclosedElements()) {
        if (e.getKind() == ElementKind.ENUM_CONSTANT) {
          enumConstants.add(e.toString());
        }
      }
      JsonPrimitive primitive=new JsonPrimitive(String.class.getName());
      primitive.setRestrictions(enumConstants);
      return primitive;
    }
 else {
      return buildType(declaredType,element);
    }
  }
}

Fixed version (ground truth):
@Override public JsonType visitDeclared(DeclaredType declaredType,Void o){
  if (_typeRecursionDetector.contains(declaredType.toString()))   return new JsonRecursiveObject(declaredType.asElement().getSimpleName().toString());
  if (isJsonPrimitive(declaredType)) {
    return new JsonPrimitive(declaredType.toString());
  }
 else   if (isInstanceOf(declaredType,Collection.class)) {
    if (declaredType.getTypeArguments().size() == 0) {
      return new JsonArray(new JsonPrimitive(Object.class.getName()));
    }
 else {
      TypeParameterElement elem=((TypeElement)declaredType.asElement()).getTypeParameters().get(0);
      _typeRecursionDetector.add(_type.toString());
      return new JsonArray(acceptOrRecurse(o,elem.asType()));
    }
  }
 else   if (isInstanceOf(declaredType,Map.class)) {
    if (declaredType.getTypeArguments().size() == 0) {
      return new JsonDict(new JsonPrimitive(Object.class.getName()),new JsonPrimitive(Object.class.getName()));
    }
 else {
      TypeMirror key=declaredType.getTypeArguments().get(0);
      TypeMirror val=declaredType.getTypeArguments().get(1);
      _typeRecursionDetector.add(_type.toString());
      JsonType keyJson=acceptOrRecurse(o,key);
      JsonType valJson=acceptOrRecurse(o,val);
      return new JsonDict(keyJson,valJson);
    }
  }
 else {
    TypeElement element=(TypeElement)declaredType.asElement();
    if (element.getKind() == ElementKind.ENUM) {
      List<String> enumConstants=new ArrayList();
      for (      Element e : element.getEnclosedElements()) {
        if (e.getKind() == ElementKind.ENUM_CONSTANT) {
          enumConstants.add(e.toString());
        }
      }
      JsonPrimitive primitive=new JsonPrimitive(String.class.getName());
      primitive.setRestrictions(enumConstants);
      return primitive;
    }
 else {
      return buildType(declaredType,element);
    }
  }
}