Package com.tonic.analysis
Class MethodGrafter
- java.lang.Object
-
- com.tonic.analysis.MethodGrafter
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MethodEntrygraftMethod(ClassFile source, MethodEntry method, ClassFile target)Graftsmethodfromsourceintotargetas a brand-new method, returning the new method entry on the target.static voidreplaceMethodBody(ClassFile source, MethodEntry sourceMethod, ClassFile target, MethodEntry targetMethod)ReplacestargetMethod's body in place withsourceMethod's, remapping every constant-pool reference into the target.
-
-
-
Method Detail
-
graftMethod
public static MethodEntry graftMethod(ClassFile source, MethodEntry method, ClassFile target)
Graftsmethodfromsourceintotargetas a brand-new method, returning the new method entry on the target.- Parameters:
source- the class file the method currently lives inmethod- the method to copytarget- the class file to copy it into- Returns:
- the newly created method on
target
-
replaceMethodBody
public static void replaceMethodBody(ClassFile source, MethodEntry sourceMethod, ClassFile target, MethodEntry targetMethod)
ReplacestargetMethod's body in place withsourceMethod's, remapping every constant-pool reference into the target.- Parameters:
source- the class filesourceMethodlives insourceMethod- the method whose body to copytarget- the class filetargetMethodlives intargetMethod- the method ontargetto overwrite (typically same name and descriptor)
-
-