Я закончил поиском решения того, что хотел.Он состоял из ExprEditor , например:
public CtClass instrumentMethods() throws CannotCompileException, IOException {
ClassPool cp = ClassPool.getDefault();
cp.insertClassPath(new LoaderClassPath(loader));
CtClass ctKlazz = cp.makeClass(instream);
CtMethod[] methods = ctKlazz.getMethods();
for (CtMethod method : methods) {
final CtBehavior method = methods[ind];
method.instrument(
new ExprEditor() {
// Instrument new expressions:
public void edit(NewExpr expr) throws CannotCompileException {
final int allocSiteId = getAllocSiteId(className, expr.indexOfBytecode());
expr.replace( "{ $_ = $proceed($$); someCodeHere($_); }");
}
}
);
method.insertBefore("{ someInstrumentationAtStart(); }");
}
return ctKlazz;
}