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?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3838085#3838085

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3838085


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to