code: public static void writeCompilationUnit(
        Filer filer,
        SourceBuilder unit,
        Element originatingElement) throws IOException {
      String typename = unit.typename().toString();
      String finalSource = unit.toString();
      try (Writer writer = filer.createSourceFile(typename, originatingElement).openWriter()) {
        writer.append(finalSource);
      }
    }
docs: Writes {@code unit} to the correct file.
  
  <p>This is complicated by an EJC bug that returns the wrong object from
  {@link Writer#append(CharSequence)}.