private String generate() {
      ClassName superclass = ClassName.get(context.packageName(), classToExtend);
      Optional<AnnotationSpec> generatedAnnotationSpec =
          GeneratedAnnotationSpecs.generatedAnnotationSpec(
              context.processingEnvironment().getElementUtils(),
              context.processingEnvironment().getSourceVersion(),
              SerializableAutoValueExtension.class);

      TypeSpec.Builder subclass =
          TypeSpec.classBuilder(className)
              .superclass(getClassTypeName(superclass, typeVariableNames))
              .addTypeVariables(typeVariableNames)
              .addModifiers(isFinal ? Modifier.FINAL : Modifier.ABSTRACT)
              .addMethod(constructor())
              .addMethod(writeReplace())
              .addType(proxyGenerator.generate());
      generatedAnnotationSpec.ifPresent(subclass::addAnnotation);

      return JavaFile.builder(context.packageName(), subclass.build()).build().toString();
    }
An AutoValue extension that enables classes with unserializable fields to be serializable.

<p>For this extension to work:

<ul>
  <li>The AutoValue class must implement {@link Serializable}.
  <li>Unserializable fields in the AutoValue class must be supported by a {@link
      com.google.auto.value.extension.serializable.serializer.interfaces.SerializerExtension}.
</ul>
value/src/main/java/com/google/auto/value/extension/serializable/processor/SerializableAutoValueExtension.java