From 54191f111328f96e2eedc5421e3ac06db0be0005 Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Thu, 21 Dec 2023 15:04:24 +0100 Subject: [PATCH] not throwing an error if not necessary when nothing was added to the CallGraph --- .../callgraph/AbstractCallGraphAlgorithm.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java index 842335ddd6b..b07da6e1747 100644 --- a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java +++ b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java @@ -313,17 +313,21 @@ protected abstract void postProcessingMethod( @Nonnull @Override public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassType classType) { - MutableCallGraph updated = oldCallGraph.copy(); - SootClass clazz = view.getClassOrThrow(classType); Set newMethodSignatures = - clazz.getMethods().stream().map(Method::getSignature).collect(Collectors.toSet()); + clazz.getMethods().stream() + .map(Method::getSignature) + .filter(methodSig -> !oldCallGraph.containsMethod(methodSig)) + .collect(Collectors.toSet()); - if (newMethodSignatures.stream().anyMatch(oldCallGraph::containsMethod)) { - // FIXME: [ms] handle better - remove from entry point signatures in this case - throw new IllegalArgumentException("CallGraph already contains methods from " + classType); + // were all the added method signatures already visited in the CallGraph? i.e. is there + // something to add? + if (newMethodSignatures.isEmpty()) { + return oldCallGraph; } + MutableCallGraph updated = oldCallGraph.copy(); + // Step 1: Add edges from the new methods to other methods Deque workList = new ArrayDeque<>(newMethodSignatures); Set processed = new HashSet<>(oldCallGraph.getMethodSignatures());