Skip to content

Commit

Permalink
Remove exception or errors from the conservative call graph
Browse files Browse the repository at this point in the history
  • Loading branch information
sarpsahinalp committed Aug 19, 2024
1 parent fd2f320 commit f5120a2
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ private Set<JavaAccess<?>> getDirectAccessTargetsOutsideOfAnalyzedClasses(JavaAc
* These classes are always generic interfaces or abstract classes
* TODO: Check if this is also the case for foreign packages
*/
if (subclasses.size() > 20) {
if (subclasses.size() > 20 || isExceptionOrError(resolvedTarget)) {
return Collections.emptySet();
}

return subclasses.stream()
.map(javaClass -> getAccessesFromClass(javaClass, item.getTarget().getFullName().substring(item.getTargetOwner().getFullName().length())))
.map(javaClass ->
getAccessesFromClass(javaClass, item.getTarget().getFullName().substring(item.getTargetOwner().getFullName().length())))
.flatMap(Set::stream)
.collect(toSet());
}
Expand All @@ -160,13 +161,18 @@ private Set<JavaAccess<?>> getAccessesFromClass(JavaClass javaClass, String meth
.getOrigin()
.getFullName()
.substring(javaClass.getFullName().length())
.equals(methodName))
.equals(methodName)
&& isExceptionOrError(a.getTargetOwner()))
.collect(toSet());
}

private JavaClass resolveTargetOwner(JavaClass targetOwner) {
Optional<JavaClass> resolvedTarget = customClassResolver.tryResolve(targetOwner.getFullName());
return resolvedTarget.orElse(targetOwner);
}

private boolean isExceptionOrError(JavaClass javaClass) {
return javaClass.isAssignableTo(Exception.class) || javaClass.isAssignableTo(Error.class);
}
}
}

0 comments on commit f5120a2

Please sign in to comment.