throws NoSuchMethodException {
Class[] outargs = new Class[]{ ObjectOutput.class };
BCMethod meth = _pc.declareMethod("writeExternal", void.class, outargs);
Exceptions exceps = meth.getExceptions(true);
exceps.addException(IOException.class);
Code code = meth.getCode(true);
// super.writeExternal (out);
Class sup = getType(_meta).getSuperclass();
if (!parentDetachable && Externalizable.class.isAssignableFrom(sup)) {
loadManagedInstance(code, false);
code.aload().setParam(0);
code.invokespecial().setMethod(sup, "writeExternal",
void.class, outargs);
}
// writeUnmanaged (out);
loadManagedInstance(code, false);
code.aload().setParam(0);
code.invokevirtual().setMethod(getType(_meta),
PRE + "WriteUnmanaged", void.class, outargs);
JumpInstruction go2 = null;
if (detachedState) {
// if (sm != null)
// if (sm.writeDetached (out))
// return;
loadManagedInstance(code, false);
code.getfield().setField(SM, SMTYPE);
IfInstruction ifnull = code.ifnull();
loadManagedInstance(code, false);
code.getfield().setField(SM, SMTYPE);
code.aload().setParam(0);
code.invokeinterface().setMethod(SMTYPE, "writeDetached",
boolean.class, outargs);
go2 = code.ifeq();
code.vreturn();
// else
// out.writeObject (pcGetDetachedState ());
Class[] objargs = new Class[]{ Object.class };
ifnull.setTarget(code.aload().setParam(0));
loadManagedInstance(code, false);
code.invokevirtual().setMethod(PRE + "GetDetachedState",
Object.class, null);
code.invokeinterface().setMethod(ObjectOutput.class,
"writeObject", void.class, objargs);
// out.writeObject (null) // StateManager
code.aload().setParam(0);
code.constant().setValue((Object) null);
code.invokeinterface().setMethod(ObjectOutput.class,
"writeObject", void.class, objargs);
}
if (go2 != null)
go2.setTarget(code.nop());
addWriteExternalFields();
loadManagedInstance(code, false);
code.aload().setParam(0);
code.invokevirtual().setMethod("writeExternalFields",
void.class, outargs);
// return
code.vreturn();
code.calculateMaxStack();
code.calculateMaxLocals();
}