Program: 155859
Project: 155859
Buggy source:
public void generate() throws IOException, UnsupportedOperationException {
  String qualifiedGeneratedClassName=String.format("String_Node_Str",packageName,className);
  JavaFileObject sourceFile=processingEnvironment.getFiler().createSourceFile(qualifiedGeneratedClassName);
  JavaWriter writer=new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
  Elements elementUtils=processingEnvironment.getElementUtils();
  Types typeUtils=processingEnvironment.getTypeUtils();
  TypeMirror realmObject=elementUtils.getTypeElement("String_Node_Str").asType();
  DeclaredType realmList=typeUtils.getDeclaredType(elementUtils.getTypeElement("String_Node_Str"),typeUtils.getWildcardType(null,null));
  writer.setIndent("String_Node_Str");
  writer.emitPackage(packageName).emitEmptyLine();
  writer.emitImports("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").emitEmptyLine();
  writer.beginType(qualifiedGeneratedClassName,"String_Node_Str",EnumSet.of(Modifier.PUBLIC),className).emitEmptyLine();
  ListIterator<VariableElement> iterator=fields.listIterator();
  while (iterator.hasNext()) {
    int columnNumber=iterator.nextIndex();
    VariableElement field=iterator.next();
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    if (JAVA_TO_REALM_TYPES.containsKey(fieldTypeCanonicalName)) {
      String realmType=JAVA_TO_REALM_TYPES.get(fieldTypeCanonicalName);
      String castingType=CASTING_TYPES.get(fieldTypeCanonicalName);
      writer.emitAnnotation("String_Node_Str");
      String getterPrefix=fieldTypeCanonicalName.equals("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
      writer.beginMethod(fieldTypeCanonicalName,getterPrefix + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,realmType,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.emitStatement("String_Node_Str",realmType,columnNumber,castingType);
      writer.endMethod();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod(fieldTypeCanonicalName,"String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.beginControlFlow("String_Node_Str",columnNumber);
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.endMethod();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      String genericCanonicalType=((DeclaredType)field.asType()).getTypeArguments().get(0).toString();
      String genericType;
      if (genericCanonicalType.contains("String_Node_Str")) {
        genericType=genericCanonicalType.substring(genericCanonicalType.lastIndexOf('.') + 1);
      }
 else {
        genericType=genericCanonicalType;
      }
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod(fieldTypeCanonicalName,"String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.emitStatement("String_Node_Str",genericType,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.endMethod();
    }
 else {
      throw new UnsupportedOperationException(String.format("String_Node_Str",fieldTypeCanonicalName,fieldName));
    }
    writer.emitEmptyLine();
  }
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.STATIC),"String_Node_Str","String_Node_Str");
  writer.beginControlFlow("String_Node_Str" + this.className + "String_Node_Str");
  writer.emitStatement("String_Node_Str",this.className);
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    String fieldTypeName;
    if (fieldTypeCanonicalName.contains("String_Node_Str")) {
      fieldTypeName=fieldTypeCanonicalName.substring(fieldTypeCanonicalName.lastIndexOf('.') + 1);
    }
 else {
      fieldTypeName=fieldTypeCanonicalName;
    }
    if (JAVA_TO_REALM_TYPES.containsKey(fieldTypeCanonicalName)) {
      writer.emitStatement("String_Node_Str",JAVA_TO_COLUMN_TYPES.get(fieldTypeCanonicalName),fieldName.toLowerCase(Locale.getDefault()));
    }
 else     if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.beginControlFlow("String_Node_Str",fieldTypeName);
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldName.toLowerCase(Locale.getDefault()),fieldTypeName);
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      String genericCanonicalType=((DeclaredType)field.asType()).getTypeArguments().get(0).toString();
      String genericType;
      if (genericCanonicalType.contains("String_Node_Str")) {
        genericType=genericCanonicalType.substring(genericCanonicalType.lastIndexOf('.') + 1);
      }
 else {
        genericType=genericCanonicalType;
      }
      writer.beginControlFlow("String_Node_Str",genericType);
      writer.emitStatement("String_Node_Str",genericCanonicalType);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldName.toLowerCase(Locale.getDefault()),genericType);
    }
  }
  writer.emitStatement("String_Node_Str");
  writer.endControlFlow();
  writer.emitStatement("String_Node_Str",this.className);
  writer.endMethod();
  writer.emitEmptyLine();
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC));
  writer.emitStatement("String_Node_Str",className);
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    String getterPrefix=fieldTypeCanonicalName.equals("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
    writer.emitStatement("String_Node_Str",fieldName);
    writer.emitStatement("String_Node_Str",getterPrefix,capitaliseFirstChar(fieldName));
    writer.emitStatement("String_Node_Str",fieldName);
  }
  writer.emitStatement("String_Node_Str");
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC));
  writer.emitStatement("String_Node_Str");
  int counter=0;
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    if (HASHCODE.containsKey(fieldTypeCanonicalName)) {
      for (      String statement : HASHCODE.get(fieldTypeCanonicalName)) {
        if (statement.contains("String_Node_Str") && statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,counter,capitaliseFirstChar(fieldName));
        }
 else         if (statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,counter,counter);
        }
 else         if (statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,capitaliseFirstChar(fieldName));
        }
 else {
          throw new AssertionError();
        }
      }
    }
 else {
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,counter,fieldName);
      writer.emitStatement("String_Node_Str",counter,counter);
    }
    counter++;
  }
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
  writer.endType();
  writer.close();
}

Fixed version (ground truth):
public void generate() throws IOException, UnsupportedOperationException {
  String qualifiedGeneratedClassName=String.format("String_Node_Str",packageName,className);
  JavaFileObject sourceFile=processingEnvironment.getFiler().createSourceFile(qualifiedGeneratedClassName);
  JavaWriter writer=new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
  Elements elementUtils=processingEnvironment.getElementUtils();
  Types typeUtils=processingEnvironment.getTypeUtils();
  TypeMirror realmObject=elementUtils.getTypeElement("String_Node_Str").asType();
  DeclaredType realmList=typeUtils.getDeclaredType(elementUtils.getTypeElement("String_Node_Str"),typeUtils.getWildcardType(null,null));
  writer.setIndent("String_Node_Str");
  writer.emitPackage(packageName).emitEmptyLine();
  writer.emitImports("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").emitEmptyLine();
  writer.beginType(qualifiedGeneratedClassName,"String_Node_Str",EnumSet.of(Modifier.PUBLIC),className).emitEmptyLine();
  ListIterator<VariableElement> iterator=fields.listIterator();
  while (iterator.hasNext()) {
    int columnNumber=iterator.nextIndex();
    VariableElement field=iterator.next();
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    if (JAVA_TO_REALM_TYPES.containsKey(fieldTypeCanonicalName)) {
      String realmType=JAVA_TO_REALM_TYPES.get(fieldTypeCanonicalName);
      String castingType=CASTING_TYPES.get(fieldTypeCanonicalName);
      writer.emitAnnotation("String_Node_Str");
      String getterPrefix=fieldTypeCanonicalName.equals("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
      writer.beginMethod(fieldTypeCanonicalName,getterPrefix + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,realmType,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.emitStatement("String_Node_Str",realmType,columnNumber,castingType);
      writer.endMethod();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod(fieldTypeCanonicalName,"String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.beginControlFlow("String_Node_Str",columnNumber);
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.endMethod();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      String genericCanonicalType=((DeclaredType)field.asType()).getTypeArguments().get(0).toString();
      String genericType;
      if (genericCanonicalType.contains("String_Node_Str")) {
        genericType=genericCanonicalType.substring(genericCanonicalType.lastIndexOf('.') + 1);
      }
 else {
        genericType=genericCanonicalType;
      }
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod(fieldTypeCanonicalName,"String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC));
      writer.emitStatement("String_Node_Str",genericType,columnNumber);
      writer.endMethod();
      writer.emitEmptyLine();
      writer.emitAnnotation("String_Node_Str");
      writer.beginMethod("String_Node_Str","String_Node_Str" + capitaliseFirstChar(fieldName),EnumSet.of(Modifier.PUBLIC),fieldTypeCanonicalName,"String_Node_Str");
      writer.emitStatement("String_Node_Str",columnNumber);
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.beginControlFlow("String_Node_Str");
      writer.emitStatement("String_Node_Str");
      writer.endControlFlow();
      writer.endMethod();
    }
 else {
      throw new UnsupportedOperationException(String.format("String_Node_Str",fieldTypeCanonicalName,fieldName));
    }
    writer.emitEmptyLine();
  }
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.STATIC),"String_Node_Str","String_Node_Str");
  writer.beginControlFlow("String_Node_Str" + this.className + "String_Node_Str");
  writer.emitStatement("String_Node_Str",this.className);
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    String fieldTypeName;
    if (fieldTypeCanonicalName.contains("String_Node_Str")) {
      fieldTypeName=fieldTypeCanonicalName.substring(fieldTypeCanonicalName.lastIndexOf('.') + 1);
    }
 else {
      fieldTypeName=fieldTypeCanonicalName;
    }
    if (JAVA_TO_REALM_TYPES.containsKey(fieldTypeCanonicalName)) {
      writer.emitStatement("String_Node_Str",JAVA_TO_COLUMN_TYPES.get(fieldTypeCanonicalName),fieldName.toLowerCase(Locale.getDefault()));
    }
 else     if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.beginControlFlow("String_Node_Str",fieldTypeName);
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldName.toLowerCase(Locale.getDefault()),fieldTypeName);
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      String genericCanonicalType=((DeclaredType)field.asType()).getTypeArguments().get(0).toString();
      String genericType;
      if (genericCanonicalType.contains("String_Node_Str")) {
        genericType=genericCanonicalType.substring(genericCanonicalType.lastIndexOf('.') + 1);
      }
 else {
        genericType=genericCanonicalType;
      }
      writer.beginControlFlow("String_Node_Str",genericType);
      writer.emitStatement("String_Node_Str",genericCanonicalType);
      writer.endControlFlow();
      writer.emitStatement("String_Node_Str",fieldName.toLowerCase(Locale.getDefault()),genericType);
    }
  }
  writer.emitStatement("String_Node_Str");
  writer.endControlFlow();
  writer.emitStatement("String_Node_Str",this.className);
  writer.endMethod();
  writer.emitEmptyLine();
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC));
  writer.emitStatement("String_Node_Str",className);
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    String getterPrefix=fieldTypeCanonicalName.equals("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
    writer.emitStatement("String_Node_Str",fieldName);
    writer.emitStatement("String_Node_Str",getterPrefix,capitaliseFirstChar(fieldName));
    writer.emitStatement("String_Node_Str",fieldName);
  }
  writer.emitStatement("String_Node_Str");
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC));
  writer.emitStatement("String_Node_Str");
  int counter=0;
  for (  VariableElement field : fields) {
    String fieldName=field.getSimpleName().toString();
    String fieldTypeCanonicalName=field.asType().toString();
    if (HASHCODE.containsKey(fieldTypeCanonicalName)) {
      for (      String statement : HASHCODE.get(fieldTypeCanonicalName)) {
        if (statement.contains("String_Node_Str") && statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,counter,capitaliseFirstChar(fieldName));
        }
 else         if (statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,counter,counter);
        }
 else         if (statement.contains("String_Node_Str")) {
          writer.emitStatement(statement,capitaliseFirstChar(fieldName));
        }
 else {
          throw new AssertionError();
        }
      }
    }
 else {
      writer.emitStatement("String_Node_Str",fieldTypeCanonicalName,counter,capitaliseFirstChar(fieldName));
      writer.emitStatement("String_Node_Str",counter,counter);
    }
    counter++;
  }
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
  writer.endType();
  writer.close();
}