This content has been marked as final.
Show 2 replies
-
1. Re: Bytecode modifications at load time with Javassist Bytec
chiba Jun 9, 2004 5:04 AM (in response to fabienbaligand)If you want to copy a whole method body, you can simply add
a CtMethod from class A to class B.
If you want to insert only part of a method body, you must use
CodeIterator. For example,
CtClass b = ... ;
CtMethod m = b.getMethod(...);
MethodInfo minfo = m.getMethodInfo();
CodeAttribute ca = minfo.getCodeAttribute();
CodeIterator it = ca.iterator();
it.insert(position, code);
code specifies a byte array containing the bytecode that you want
to inject. For details, please look at the last section of the tutorial
of version 3.
Is this what you need? -
2. Re: Bytecode modifications at load time with Javassist Bytec
fabienbaligand Jun 9, 2004 10:49 AM (in response to fabienbaligand)Thank you Shiba,
I think I should be fine with your explanations.