Skip to content

Commit 4106130

Browse files
raintungmbenz89
authored andcommitted
fix the loop transitive
1 parent b923103 commit 4106130

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/soot/ModuleUtil.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
import java.nio.file.Path;
3737
import java.nio.file.Paths;
3838
import java.util.ArrayList;
39+
import java.util.HashSet;
3940
import java.util.List;
4041
import java.util.Map;
42+
import java.util.Set;
4143
import java.util.concurrent.ExecutionException;
4244
import java.util.regex.Pattern;
4345

@@ -142,7 +144,8 @@ public final String findModuleThatExports(String className, String toModuleName)
142144
modulePackageCache.put(modInfo.getModuleName() + "/" + packageName, modInf.getModuleName());
143145
return modInf.getModuleName();
144146
} else {
145-
String tModuleName = checkTransitiveChain(modInf, packageName, toModuleName);
147+
Set<String> hasCheckedModule = new HashSet<String>();
148+
String tModuleName = checkTransitiveChain(modInf, packageName, toModuleName, hasCheckedModule);
146149
if(tModuleName != null) {
147150
modulePackageCache.put(modInfo.getModuleName() + "/" + packageName, tModuleName);
148151
return tModuleName;
@@ -162,13 +165,18 @@ public final String findModuleThatExports(String className, String toModuleName)
162165
* @param toModuleName defined moduleName
163166
*
164167
*/
165-
private String checkTransitiveChain(SootModuleInfo modInfo, String packageName, String toModuleName) {
168+
private String checkTransitiveChain(SootModuleInfo modInfo, String packageName, String toModuleName, Set<String> hasCheckedModule) {
166169
for (Map.Entry<SootModuleInfo, Integer> entry : modInfo.retrieveRequiredModules().entrySet()) {
167170
if ((entry.getValue() & Modifier.REQUIRES_TRANSITIVE) != 0) {// check if module is exported via "requires public"
171+
if(hasCheckedModule.contains(entry.getKey().getModuleName())) {
172+
continue;
173+
} else {
174+
hasCheckedModule.add(entry.getKey().getModuleName());
175+
}
168176
if (entry.getKey().exportsPackage(packageName, toModuleName)) {
169177
return entry.getKey().getModuleName();
170178
} else {
171-
return checkTransitiveChain(entry.getKey(), packageName, toModuleName);
179+
return checkTransitiveChain(entry.getKey(), packageName, toModuleName, hasCheckedModule);
172180
}
173181
}
174182
}

0 commit comments

Comments
 (0)