Skip to content

Commit 458249c

Browse files
committed
bugfix clone collection and only then iterate on it to avoid ConcurrentModificationException
1 parent 5a5576d commit 458249c

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/soot/jbco/jimpleTransformations/MethodRenamer.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,29 @@
1919

2020
package soot.jbco.jimpleTransformations;
2121

22-
import java.util.*;
23-
import soot.*;
22+
import java.util.ArrayList;
23+
import java.util.HashMap;
24+
import java.util.Iterator;
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.Vector;
28+
import soot.Body;
29+
import soot.FastHierarchy;
30+
import soot.G;
31+
import soot.Hierarchy;
32+
import soot.Scene;
33+
import soot.SceneTransformer;
34+
import soot.SootClass;
35+
import soot.SootField;
36+
import soot.SootMethod;
37+
import soot.SootMethodRef;
38+
import soot.Unit;
39+
import soot.Value;
40+
import soot.ValueBox;
2441
import soot.jbco.IJbcoTransform;
25-
import soot.jbco.util.*;
26-
import soot.jimple.*;
42+
import soot.jbco.util.BodyBuilder;
43+
import soot.jbco.util.Rand;
44+
import soot.jimple.InvokeExpr;
2745

2846
/**
2947
* @author Michael Batchelder
@@ -74,7 +92,8 @@ protected void internalTransform(String phaseName,
7492
fields.add(fIt.next().getName());
7593
}
7694

77-
for (SootMethod m : c.getMethods()) {
95+
final List<SootMethod> methods = new ArrayList<>(c.getMethods());
96+
for (SootMethod m : methods) {
7897
String subSig = m.getSubSignature();
7998

8099
if (!allowsRename(c, m))
@@ -119,7 +138,8 @@ protected void internalTransform(String phaseName,
119138
}
120139

121140
for (SootClass c : scene.getApplicationClasses()) {
122-
for (SootMethod m : c.getMethods()) {
141+
final List<SootMethod> methods = new ArrayList<>(c.getMethods());
142+
for (SootMethod m : methods) {
123143
if (!m.isConcrete() || m.getDeclaringClass().isLibraryClass())
124144
continue;
125145
Body aBody = null;

0 commit comments

Comments
 (0)