// This is the "magic" signature that allows an object to substitute some other
// object for itself.
MethodSignature writeReplaceSig = new MethodSignature(Object.class, "writeReplace", null, new Class[]
{ ObjectStreamException.class });
classFab.addMethod(Modifier.PRIVATE, writeReplaceSig, "return token;");
// Now delegate all the methods.
String body = format("return (%s) creator.createObject();", serviceInterface.getName());