final int accessFlags = JDO_PC_jdoCopyFields_Mods;
final ExceptionsAttribute exceptAttr = null;
// begin of method body
final InsnTarget begin = new InsnTarget();
Insn insn = begin;
// check sm
insn = appendCheckStateManager(insn, 0,
JAVA_IllegalStateException_Path,
"arg0." + JDO_PC_jdoStateManager_Name);
// check pc argument
final ConstClass thisConstClass = classFile.className();
affirm(thisConstClass != null);
insn = appendCheckVarInstanceOf(insn, 1, thisConstClass,
JAVA_IllegalArgumentException_Path,
"arg1");
// check fieldnumbers argument
insn = appendCheckVarNonNull(insn, 2,
JAVA_IllegalArgumentException_Path,
"arg2");
// downcast argument
insn = insn.append(Insn.create(opc_aload_1));
insn = insn.append(Insn.create(opc_checkcast, thisConstClass));
insn = insn.append(Insn.create(opc_astore_3));
// check this and argument's sm for equality
final InsnTarget endcheck = new InsnTarget();
insn = insn.append(Insn.create(opc_aload_3));
insn = insn.append(
Insn.create(
opc_getfield,
getjdoStateManagerFieldRef()));
insn = insn.append(Insn.create(opc_aload_0));
insn = insn.append(
Insn.create(
opc_getfield,
getjdoStateManagerFieldRef()));
insn = insn.append(Insn.create(opc_if_acmpeq, endcheck));
insn = appendThrowJavaException(insn,
JAVA_IllegalArgumentException_Path,
"arg1." + JDO_PC_jdoStateManager_Name);
// store the array argument length into local var
insn = insn.append(endcheck);
insn = insn.append(Insn.create(opc_aload_2));
insn = insn.append(Insn.create(opc_arraylength));
insn = insn.append(Insn.create(opc_istore, 4));
// init loop counter and goto loop check
final InsnTarget loopcheck = new InsnTarget();
insn = insn.append(Insn.create(opc_iconst_0));
insn = insn.append(Insn.create(opc_istore, 5));
insn = insn.append(Insn.create(opc_goto, loopcheck));
// loop body: call self-delegating method with arguments
final InsnTarget loopbody = new InsnTarget();
insn = insn.append(loopbody);
insn = insn.append(Insn.create(opc_aload_0));
insn = insn.append(Insn.create(opc_aload_3));
// select element from array argument at loop counter
insn = insn.append(Insn.create(opc_aload_2));
insn = insn.append(Insn.create(opc_iload, 5));
insn = insn.append(Insn.create(opc_iaload));
// call self-delegating method
final String delegateName = JDO_PC_jdoCopyField_Name;
final String delegateSig
= JDONameHelper.getJDO_PC_jdoCopyField_Sig(className);
insn = insn.append(
Insn.create(opc_invokevirtual,
pool.addMethodRef(
className,
delegateName,
delegateSig)));
// loop counter increment
insn = insn.append(new InsnIInc(5, 1));
// loop termination check
insn = insn.append(loopcheck);
insn = insn.append(Insn.create(opc_iload, 5));
insn = insn.append(Insn.create(opc_iload, 4));
insn = insn.append(Insn.create(opc_if_icmplt, loopbody));
// end of method body
insn = insn.append(Insn.create(opc_return));
final CodeAttribute codeAttr
= new CodeAttribute(getCodeAttributeUtf8(),
4, // maxStack
6, // maxLocals