Skip to content

Commit 4dfe87f

Browse files
committed
not throwing an error if not necessary when nothing was added to the CallGraph
1 parent 011a239 commit 4dfe87f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,17 @@ protected abstract void postProcessingMethod(
313313
@Nonnull
314314
@Override
315315
public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassType classType) {
316-
MutableCallGraph updated = oldCallGraph.copy();
317-
318316
SootClass<?> clazz = view.getClassOrThrow(classType);
319317
Set<MethodSignature> newMethodSignatures =
320-
clazz.getMethods().stream().map(Method::getSignature).collect(Collectors.toSet());
318+
clazz.getMethods().stream().map(Method::getSignature).filter(methodSig -> !oldCallGraph.containsMethod(methodSig)).collect(Collectors.toSet());
321319

322-
if (newMethodSignatures.stream().anyMatch(oldCallGraph::containsMethod)) {
323-
// FIXME: [ms] handle better - remove from entry point signatures in this case
324-
throw new IllegalArgumentException("CallGraph already contains methods from " + classType);
320+
// were all the added method signatures already visited in the CallGraph? i.e. is there something to add?
321+
if (newMethodSignatures.isEmpty()) {
322+
return oldCallGraph;
325323
}
326324

325+
MutableCallGraph updated = oldCallGraph.copy();
326+
327327
// Step 1: Add edges from the new methods to other methods
328328
Deque<MethodSignature> workList = new ArrayDeque<>(newMethodSignatures);
329329
Set<MethodSignature> processed = new HashSet<>(oldCallGraph.getMethodSignatures());

0 commit comments

Comments
 (0)