Skip to content

Commit 8e0dc55

Browse files
committed
Use concurrent multi hashmap
1 parent 67a2679 commit 8e0dc55

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

soot-infoflow-android/src/soot/jimple/infoflow/android/callbacks/AbstractCallbackAnalyzer.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import soot.toolkits.graph.ExceptionalUnitGraph;
7777
import soot.toolkits.graph.ExceptionalUnitGraphFactory;
7878
import soot.toolkits.scalar.SimpleLocalDefs;
79+
import soot.util.ConcurrentHashMultiMap;
7980
import soot.util.HashMultiMap;
8081
import soot.util.MultiMap;
8182

@@ -129,8 +130,8 @@ public abstract class AbstractCallbackAnalyzer {
129130
protected final MultiMap<SootClass, AndroidCallbackDefinition> callbackMethods = new HashMultiMap<>();
130131
protected final MultiMap<SootClass, Integer> layoutClasses = new HashMultiMap<>();
131132
protected final Set<SootClass> dynamicManifestComponents = Collections.newSetFromMap(new ConcurrentHashMap<>());
132-
protected final MultiMap<SootClass, SootClass> fragmentClasses = new HashMultiMap<>();
133-
protected final MultiMap<SootClass, SootClass> fragmentClassesRev = new HashMultiMap<>();
133+
protected final MultiMap<SootClass, SootClass> fragmentClasses = new ConcurrentHashMultiMap<>();
134+
protected final MultiMap<SootClass, SootClass> fragmentClassesRev = new ConcurrentHashMultiMap<>();
134135
protected final Map<SootClass, Integer> fragmentIDs = new ConcurrentHashMap<>();
135136

136137
protected final List<ICallbackFilter> callbackFilters = new ArrayList<>();
@@ -201,7 +202,7 @@ else if (arrayLocals.contains(lop))
201202

202203
});
203204

204-
private MultiMap<SootMethod, Stmt> javaScriptInterfaces = new HashMultiMap<SootMethod, Stmt>();
205+
private MultiMap<SootMethod, Stmt> javaScriptInterfaces = new ConcurrentHashMultiMap<SootMethod, Stmt>();
205206

206207
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<SootClass> entryPointClasses)
207208
throws IOException {
@@ -454,9 +455,7 @@ protected void analyzeMethodForJavascriptInterfaces(SootMethod method) {
454455
final SootMethodRef methodRef = iexpr.getMethodRef();
455456
if (methodRef.getName().equals("addJavascriptInterface") && iexpr.getArgCount() == 2
456457
&& fastHierarchy.canStoreType(methodRef.getDeclaringClass().getType(), webViewType)) {
457-
synchronized (javaScriptInterfaces) {
458-
this.javaScriptInterfaces.put(method, stmt);
459-
}
458+
this.javaScriptInterfaces.put(method, stmt);
460459
}
461460
}
462461
}
@@ -993,10 +992,8 @@ && isEmpty(method.retrieveActiveBody()))
993992
if (!filterAccepts(lifecycleClass, method))
994993
return false;
995994

996-
synchronized (this.callbackMethods) {
997-
return this.callbackMethods.put(lifecycleClass,
998-
new AndroidCallbackDefinition(method, parentMethod, callbackType));
999-
}
995+
return this.callbackMethods.put(lifecycleClass,
996+
new AndroidCallbackDefinition(method, parentMethod, callbackType));
1000997
}
1001998

1002999
/**
@@ -1006,7 +1003,7 @@ && isEmpty(method.retrieveActiveBody()))
10061003
* fragment belongs
10071004
* @param fragmentClass The fragment class
10081005
*/
1009-
protected synchronized void checkAndAddFragment(SootClass componentClass, SootClass fragmentClass) {
1006+
protected void checkAndAddFragment(SootClass componentClass, SootClass fragmentClass) {
10101007
this.fragmentClasses.put(componentClass, fragmentClass);
10111008
this.fragmentClassesRev.put(fragmentClass, componentClass);
10121009
}

soot-infoflow-android/src/soot/jimple/infoflow/android/callbacks/DefaultCallbackAnalyzer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes")
9090

9191
// Do we have to start from scratch or do we have a worklist to
9292
// process?
93+
9394
if (callbackWorklist == null) {
9495
logger.info("Collecting callbacks in DEFAULT mode...");
9596
callbackWorklist = new HashMultiMap<>();
@@ -298,12 +299,13 @@ protected void checkAndAddFragment(SootClass componentClass, SootClass fragmentC
298299
private void findClassLayoutMappings() {
299300
if (rmIterator == null)
300301
rmIterator = Scene.v().getReachableMethods().listener();
302+
final SystemClassHandler handler = SystemClassHandler.v();
301303
while (rmIterator.hasNext()) {
302304
SootMethod sm = rmIterator.next().method();
303305

304306
if (!sm.isConcrete())
305307
continue;
306-
if (SystemClassHandler.v().isClassInSystemPackage(sm.getDeclaringClass()))
308+
if (handler.isClassInSystemPackage(sm.getDeclaringClass()))
307309
continue;
308310
for (Unit u : sm.retrieveActiveBody().getUnits()) {
309311
if (u instanceof Stmt) {

0 commit comments

Comments
 (0)