how to take the methods of other classes invoked in a specific method?
EXAMPLE
method getItem1()
public String getItem1() throws UnsupportedEncodingException{
String a = "2";
a.getBytes();
a.getBytes("we");
System.out.println(a);
int t = Integer.parseInt(a);
return a;
}
The methods called in getItem1() are:
String.getBytes()String.getBytes(String)PrintStream.println(String)Integer.parseInt(String)
I would do this with javassist.
So let’s say you have the following class accessible in your classpath and want to find all methods invoked from getItem1():
And you have this MyClass compiled.
Create another class that uses javassist api:
the output of the MethodFinder run is: