static byte[] makeConstructorForwarder(
      String forwardingClassName,
      TypeMirror classToConstruct,
      ImmutableList<TypeMirror> constructorParameters) {

    ClassWriter classWriter = new ClassWriter(COMPUTE_MAXS);
    classWriter.visit(
        V1_8,
        ACC_FINAL | ACC_SUPER,
        internalName(forwardingClassName),
        null,
        "java/lang/Object",
        null);
    classWriter.visitSource(forwardingClassName, null);

    // Generate the `of` method.
    // TODO(emcmanus): cleaner generics. If we're constructing Foo<T extends Number> then we should
    // generate a generic signature for the `of` method, as if the Java declaration were this:
    //   static <T extends Number> Foo<T> of(...)
    // Currently we just generate:
    //   static Foo of(...)
    // which returns the raw Foo type.
    String parameterSignature =
        constructorParameters.stream()
            .map(ForwardingClassGenerator::signatureEncoding)
            .collect(joining(""));
    String internalClassToConstruct = internalName(asTypeElement(classToConstruct));
    String ofMethodSignature = "(" + parameterSignature + ")L" + internalClassToConstruct + ";";
    MethodVisitor ofMethodVisitor =
        classWriter.visitMethod(ACC_STATIC, "of", ofMethodSignature, null, null);
    ofMethodVisitor.visitCode();

    // The remaining instructions are basically what ASMifier generates for a class like the
    // `Forwarder` class in the example above.
    ofMethodVisitor.visitTypeInsn(NEW, internalClassToConstruct);
    ofMethodVisitor.visitInsn(DUP);

    int local = 0;
    for (TypeMirror type : constructorParameters) {
      ofMethodVisitor.visitVarInsn(loadInstruction(type), local);
      local += localSize(type);
    }
    String constructorToCallSignature = "(" + parameterSignature + ")V";
    ofMethodVisitor.visitMethodInsn(
        INVOKESPECIAL,
        internalClassToConstruct,
        "<init>",
        constructorToCallSignature,
        /* isInterface= */ false);

    ofMethodVisitor.visitInsn(ARETURN);
    ofMethodVisitor.visitMaxs(0, 0);
    ofMethodVisitor.visitEnd();
    classWriter.visitEnd();
    return classWriter.toByteArray();
  }
Assembles a class with a static method {@code of} that calls the constructor of another class
with the same parameters.

<p>It would be simpler if we could just pass in an {@code ExecutableElement} representing the
constructor, but if it is synthetic then it won't be visible to the {@code javax.lang.model}
APIs. So we have to pass the constructed type and the constructor parameter types separately.

@param forwardingClassName the fully-qualified name of the class to generate
@param classToConstruct the type whose constructor will be invoked ({@code ConstructMe} in the
    example above)
@param constructorParameters the erased types of the constructor parameters, which will also be
    the types of the generated {@code of} method. We require the types to be erased so as not
    to require an instance of the {@code Types} interface to erase them here. Having to deal
    with generics would complicate things unnecessarily.
@return a byte array making up the new class file
value/src/main/java/com/google/auto/value/processor/ForwardingClassGenerator.java