diff --git a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java index eb899f1e0af..0cb5d0c7275 100644 --- a/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java +++ b/sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java @@ -291,7 +291,7 @@ protected final T findMethodInHierarchy( if (optSc.isPresent()) { SootClass sc = optSc.get(); - List superClasses = view.getTypeHierarchy().superClassesOf(sc.getType()); + List superClasses = view.getTypeHierarchy().incompleteSuperClassesOf(sc.getType()); Set interfaces = view.getTypeHierarchy().implementedInterfacesOf(sc.getType()); superClasses.addAll(interfaces); @@ -364,7 +364,7 @@ public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassTyp processWorkList(view, workList, processed, updated); // Step 2: Add edges from old methods to methods overridden in the new class - List superClasses = view.getTypeHierarchy().superClassesOf(classType); + List superClasses = view.getTypeHierarchy().incompleteSuperClassesOf(classType); Set implementedInterfaces = view.getTypeHierarchy().implementedInterfacesOf(classType); Stream superTypes = @@ -376,7 +376,9 @@ public CallGraph addClass(@Nonnull CallGraph oldCallGraph, @Nonnull JavaClassTyp .collect(Collectors.toSet()); superTypes - .map(view::getClassOrThrow) + .map(view::getClass) + .filter(Optional::isPresent) + .map(Optional::get) .flatMap(superType -> superType.getMethods().stream()) .map(Method::getSignature) .filter( diff --git a/sootup.core/src/main/java/sootup/core/typehierarchy/TypeHierarchy.java b/sootup.core/src/main/java/sootup/core/typehierarchy/TypeHierarchy.java index 5efed1cff0c..5a5b0e1ab59 100644 --- a/sootup.core/src/main/java/sootup/core/typehierarchy/TypeHierarchy.java +++ b/sootup.core/src/main/java/sootup/core/typehierarchy/TypeHierarchy.java @@ -154,7 +154,7 @@ default boolean isSubtype(@Nonnull Type supertype, @Nonnull Type potentialSubtyp return (supertypeName.equals("java.lang.Object") && !potentialSubtypeName.equals("java.lang.Object")) || supertype.equals(superClassOf((ClassType) potentialSubtype)) - || superClassesOf((ClassType) potentialSubtype).contains(supertype) + || incompleteSuperClassesOf((ClassType) potentialSubtype).contains(supertype) || implementedInterfacesOf((ClassType) potentialSubtype).contains(supertype); } else if (potentialSubtype instanceof ArrayType) { // Arrays are subtypes of java.lang.Object, java.io.Serializable and java.lang.Cloneable diff --git a/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java b/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java index 682edb9333a..f891055ad5f 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java +++ b/sootup.java.core/src/main/java/sootup/java/core/views/JavaView.java @@ -130,11 +130,7 @@ public synchronized Optional getClass(@Nonnull ClassType type) { Optional> abstractClass = getAbstractClass(type); - if (!abstractClass.isPresent()) { - return Optional.empty(); - } - - return buildClassFrom(abstractClass.get()); + return abstractClass.flatMap(this::buildClassFrom); } /** Returns the amount of classes that are currently stored in the cache. */