Skip to content

Commit

Permalink
Merge pull request #681 from soot-oss/fixHandleCorrectExceptionInInco…
Browse files Browse the repository at this point in the history
…mpleteSuperClasses

adapted incompleteSuperclassesOf to the new thrown exception in the c…
  • Loading branch information
stschott authored Sep 8, 2023
2 parents 3ca576d + 32f856e commit caa4892
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sootup.core.frontend.ResolveException;
import sootup.core.types.*;
import sootup.core.views.View;

Expand Down Expand Up @@ -198,7 +197,7 @@ default List<ClassType> incompleteSuperClassesOf(@Nonnull ClassType classType) {
superClasses.add(currentSuperClass);
currentSuperClass = superClassOf(currentSuperClass);
}
} catch (ResolveException ex) {
} catch (IllegalArgumentException ex) {
logger.warn(
"Could not find "
+ (currentSuperClass != null ? currentSuperClass : classType)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package sootup.tests.typehierarchy.viewtypehierarchytestcase;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static sootup.core.util.ImmutableUtils.immutableList;

import categories.Java8Test;
import com.google.common.collect.ImmutableList;
import java.util.List;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import sootup.core.typehierarchy.ViewTypeHierarchy;
import sootup.core.types.ClassType;
import sootup.tests.typehierarchy.JavaTypeHierarchyTestBase;

/** @author Jonas Klauke * */
@Category(Java8Test.class)
public class IncompleteSuperclassTest extends JavaTypeHierarchyTestBase {
@Test
public void method() {
ViewTypeHierarchy typeHierarchy =
(ViewTypeHierarchy) customTestWatcher.getView().getTypeHierarchy();
List<ClassType> superclasses =
typeHierarchy.incompleteSuperClassesOf(getClassType("SubClassB"));
ClassType object = getClassType("java.lang.Object");
ImmutableList<ClassType> expectedSuperClasses =
immutableList(getClassType("SubClassA"), object);
assertEquals(expectedSuperClasses, superclasses);
assertFalse(customTestWatcher.getView().getClass(object).isPresent());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class SubClassA {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class SubClassB extends SubClassA {

}

0 comments on commit caa4892

Please sign in to comment.