Program: 25596
Project: 25596
Buggy source:
void writeFactory(final FactoryDescriptor descriptor,Element originatingElement) throws IOException {
  JavaFileObject sourceFile=filer.createSourceFile(descriptor.name(),originatingElement);
  JavaWriter writer=new JavaWriter(sourceFile.openWriter());
  String packageName=getPackage(descriptor.name()).toString();
  writer.emitPackage(packageName).emitImports("String_Node_Str");
  writer.emitImports("String_Node_Str");
  if (!descriptor.providerNames().isEmpty()) {
    writer.emitImports("String_Node_Str");
  }
  for (  String implementingType : descriptor.implementingTypes()) {
    String implementingPackageName=getPackage(implementingType).toString();
    if (!"String_Node_Str".equals(implementingPackageName) && !packageName.equals(implementingPackageName)) {
      writer.emitImports(implementingType);
    }
  }
  String[] implementedClasses=FluentIterable.from(descriptor.implementingTypes()).transform(new Function<String,String>(){
    @Override public String apply(    String implemetingClass){
      return getSimpleName(implemetingClass).toString();
    }
  }
).toSortedSet(Ordering.natural()).toArray(new String[0]);
  String factoryName=getSimpleName(descriptor.name()).toString();
  writer.emitAnnotation(Generated.class,ImmutableMap.of("String_Node_Str","String_Node_Str" + AutoFactoryProcessor.class.getName() + "String_Node_Str")).beginType(factoryName,"String_Node_Str",Modifier.FINAL,null,implementedClasses);
  ImmutableList.Builder<String> constructorTokens=ImmutableList.builder();
  for (  Entry<Key,String> entry : descriptor.providerNames().entrySet()) {
    Key key=entry.getKey();
    String providerName=entry.getValue();
    writer.emitField("String_Node_Str" + key.getType() + "String_Node_Str",providerName,Modifier.PRIVATE | Modifier.FINAL);
    Optional<String> qualifier=key.getQualifier();
    String qualifierPrefix=qualifier.isPresent() ? "String_Node_Str" + qualifier.get() + "String_Node_Str" : "String_Node_Str";
    constructorTokens.add(qualifierPrefix + "String_Node_Str" + key.getType()+ "String_Node_Str").add(providerName);
  }
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod(null,factoryName,0,constructorTokens.build().toArray(new String[0]));
  for (  String providerName : descriptor.providerNames().values()) {
    writer.emitStatement("String_Node_Str",providerName);
  }
  writer.endMethod();
  for (  final FactoryMethodDescriptor methodDescriptor : descriptor.methodDescriptors()) {
    writer.beginMethod(methodDescriptor.returnType(),methodDescriptor.name(),0,parameterTokens(methodDescriptor.passedParameters()));
    FluentIterable<String> creationParameterNames=FluentIterable.from(methodDescriptor.creationParameters()).transform(new Function<Parameter,String>(){
      @Override public String apply(      Parameter parameter){
        return methodDescriptor.passedParameters().contains(parameter) ? parameter.name() : descriptor.providerNames().get(parameter.asKey()) + "String_Node_Str";
      }
    }
);
    writer.emitStatement("String_Node_Str",writer.compressType(methodDescriptor.returnType()),argumentJoiner.join(creationParameterNames));
    writer.endMethod();
  }
  writer.endType();
  writer.close();
}

Fixed version (ground truth):
void writeFactory(final FactoryDescriptor descriptor) throws IOException {
  JavaFileObject sourceFile=filer.createSourceFile(descriptor.name());
  JavaWriter writer=new JavaWriter(sourceFile.openWriter());
  String packageName=getPackage(descriptor.name()).toString();
  writer.emitPackage(packageName).emitImports("String_Node_Str");
  writer.emitImports("String_Node_Str");
  if (!descriptor.providerNames().isEmpty()) {
    writer.emitImports("String_Node_Str");
  }
  for (  String implementingType : descriptor.implementingTypes()) {
    String implementingPackageName=getPackage(implementingType).toString();
    if (!"String_Node_Str".equals(implementingPackageName) && !packageName.equals(implementingPackageName)) {
      writer.emitImports(implementingType);
    }
  }
  String[] implementedClasses=FluentIterable.from(descriptor.implementingTypes()).transform(new Function<String,String>(){
    @Override public String apply(    String implemetingClass){
      return getSimpleName(implemetingClass).toString();
    }
  }
).toSortedSet(Ordering.natural()).toArray(new String[0]);
  String factoryName=getSimpleName(descriptor.name()).toString();
  writer.emitAnnotation(Generated.class,ImmutableMap.of("String_Node_Str","String_Node_Str" + AutoFactoryProcessor.class.getName() + "String_Node_Str")).beginType(factoryName,"String_Node_Str",Modifier.FINAL,null,implementedClasses);
  ImmutableList.Builder<String> constructorTokens=ImmutableList.builder();
  for (  Entry<Key,String> entry : descriptor.providerNames().entrySet()) {
    Key key=entry.getKey();
    String providerName=entry.getValue();
    writer.emitField("String_Node_Str" + key.getType() + "String_Node_Str",providerName,Modifier.PRIVATE | Modifier.FINAL);
    Optional<String> qualifier=key.getQualifier();
    String qualifierPrefix=qualifier.isPresent() ? "String_Node_Str" + qualifier.get() + "String_Node_Str" : "String_Node_Str";
    constructorTokens.add(qualifierPrefix + "String_Node_Str" + key.getType()+ "String_Node_Str").add(providerName);
  }
  writer.emitAnnotation("String_Node_Str");
  writer.beginMethod(null,factoryName,0,constructorTokens.build().toArray(new String[0]));
  for (  String providerName : descriptor.providerNames().values()) {
    writer.emitStatement("String_Node_Str",providerName);
  }
  writer.endMethod();
  for (  final FactoryMethodDescriptor methodDescriptor : descriptor.methodDescriptors()) {
    writer.beginMethod(methodDescriptor.returnType(),methodDescriptor.name(),0,parameterTokens(methodDescriptor.passedParameters()));
    FluentIterable<String> creationParameterNames=FluentIterable.from(methodDescriptor.creationParameters()).transform(new Function<Parameter,String>(){
      @Override public String apply(      Parameter parameter){
        return methodDescriptor.passedParameters().contains(parameter) ? parameter.name() : descriptor.providerNames().get(parameter.asKey()) + "String_Node_Str";
      }
    }
);
    writer.emitStatement("String_Node_Str",writer.compressType(methodDescriptor.returnType()),argumentJoiner.join(creationParameterNames));
    writer.endMethod();
  }
  writer.endType();
  writer.close();
}