BCMethod method = _pc.declareMethod("writeReplace", Object.class, null);
method.getExceptions(true).addException(ObjectStreamException.class);
Code code = method.getCode(true);
// Object o = new <managed-type>()
code.anew().setType(_managedType); // for return
code.dup(); // for post-<init> work
code.dup(); // for <init>
code.invokespecial().setMethod(_managedType.getType(), "<init>",
void.class, null);