[Soot-list] ConcurrentModificationException when invoking getMethods()
Fang Zhou
timchou.hit at gmail.com
Mon May 6 14:09:46 EDT 2019
Hi all,
I am trying to get all functions' arguments with soot. However, when I
use getMethods() or iterator on the list of methods, I always get such
error message:
"Exception in thread "main" java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
at java.util.ArrayList$Itr.next(ArrayList.java:859)
at soot.SootClass$1.next(SootClass.java:505)
at soot.SootClass$1.next(SootClass.java:494)"
Why is the list of methods changed during my program since I do not
run any analysis yet?
Below is the code I use:
public class Test {
public static void main(String[] args) {
String classPath = args[0];
configureSoot(classPath);
Scene.v().loadNecessaryClasses();
Iterator<SootClass> scIter =
Scene.v().getApplicationClasses().snapshotIterator();
while (scIter.hasNext()) {
SootClass sc = scIter.next();
System.out.println("ClassName: " +
sc.getName() + ", Methods: " + sc.getMethodCount());
//SootMethod sMethod = sc.getMethods();
Iterator<SootMethod> smIter = sc.methodIterator();
while (smIter.hasNext()) {
//Error happens
SootMethod sMethod = smIter.next();
... ... ...
}
private static void configureSoot(String classpath) {
Options.v().set_whole_program(true);
Options.v().set_allow_phantom_refs(true);
Options.v().set_prepend_classpath(true);
Options.v().set_src_prec(Options.src_prec_class);
ArrayList<String> list = new ArrayList<>();
list.add(classpath);
Options.v().set_process_dir(list);
Options.v().set_output_dir("/tmp/sootOutput");
}
}
Thanks,
Fang
More information about the Soot-list
mailing list