I would like to list all methods called by a method.
void create() throws MyException {
System.out.println("TEST");
of("String").map(String::valueOf).get();
}
In this method i would like to list
- System.out.println
- of
- map
- String::valueOf
- get();
I have used to following code , from how to find all methods called in a method?
public class MethodFinder {
public static void main(String[] args) throws Throwable {
ClassPool cp = ClassPool.getDefault();
CtClass ctClass = cp.get("MyClass");
CtMethod method = ctClass.getDeclaredMethod("getItem1");
method.instrument(
new ExprEditor() {
public void edit(MethodCall m)
throws CannotCompileException
{
System.out.println(m.getClassName() + "." + m.getMethodName() + " " + m.getSignature());
}
});
}
}
And get all methods except the String::valueOf
Aucun commentaire:
Enregistrer un commentaire