With the following code I can get the jimple
representation of a java .class
file:
soot.Main.main(args);
SootClass mainClass = Scene.v().getMainClass();
String methodSignature = "void main(java.lang.String[])";
SootMethod mainMethod = mainClass.getMethod(methodSignature);
Body jimpleBody = mainMethod.retrieveActiveBody();
However, I need to know the map from .class
to jimple
. In detail, For a certain line of code in the .class
file, I want to know its corresponding jimple
representation. Since one line of code can be converted into multiple jimple
codes, this map can be one-to-many. Does there exist any API or method that can solve this problem?
I find the solution here . In detail, for a Unit
you can use
Unit unit = ...
int sourceID = unit.getJavaSourceStartLineNumber();
// do something smart here ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.