// check the found method
affirm(!method.isAbstract(),
"Attempt to add code to an abstract method.");
affirm(!method.isNative(),
"Attempt to add code to a native method.");
final CodeAttribute foundCodeAttr = method.codeAttribute();
affirm(foundCodeAttr != null); // by JVM spec
// prepend the new code to the current one
final Insn firstInsn = codeAttr.theCode();
affirm(firstInsn != null);
final Insn foundFirstInsn = foundCodeAttr.theCode();
affirm(foundFirstInsn != null);
final Insn lastInsn = firstInsn.append(foundFirstInsn);
affirm(lastInsn != null);
foundCodeAttr.setTheCode(firstInsn);
// ajust the method's stack and locals demand
foundCodeAttr.setStackUsed(max(foundCodeAttr.stackUsed(),
codeAttr.stackUsed()));
foundCodeAttr.setLocalsUsed(max(foundCodeAttr.localsUsed(),
codeAttr.localsUsed()));
// add the exception attribute or its exceptions
if (exceptAttr != null) {
affirm((exceptAttr.getExceptions().size()