/** * Returns a list of superclasses of {@code sootClass}, including itself. * * @param sootClass * the <strong>class</strong> of which superclasses will be taken. Must not be {@code null} or interface * @return list of superclasses, including itself * @throws IllegalArgumentException * when passed class is an interface * @throws NullPointerException * when passed argument is {@code null} */ public List<SootClass> getSuperclassesOfIncluding(SootClass sootClass) { final List<SootClass> superclasses = getSuperclassesOf(sootClass); final List<SootClass> result = new ArrayList<>(superclasses.size() + 1); result.add(sootClass); result.addAll(superclasses); return Collections.unmodifiableList(result); }
/** * Get whole tree of interfaces on {@code Scene} for class/interface. * * @param sc * class or interface to get all its interfaces * @return all interfaces on {@code Scene} for class or interface */ public static List<SootClass> getAllInterfacesOf(SootClass sc) { Hierarchy hierarchy = Scene.v().getActiveHierarchy(); Stream<SootClass> superClassInterfaces = sc.isInterface() ? Stream.empty() : hierarchy.getSuperclassesOf(sc).stream().map(HierarchyUtils::getAllInterfacesOf).flatMap(Collection::stream); Stream<SootClass> directInterfaces = Stream.concat(sc.getInterfaces().stream(), sc.getInterfaces().stream().map(HierarchyUtils::getAllInterfacesOf).flatMap(Collection::stream)); return Stream.concat(superClassInterfaces, directInterfaces).collect(toList()); }
/** * Returns true if child is a subclass of possibleParent. If one of the known parent classes is phantom, we conservatively * assume that the current class might be a child. */ public boolean isClassSubclassOf(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); List<SootClass> parentClasses = getSuperclassesOf(child); if (parentClasses.contains(possibleParent)) { return true; } for (SootClass sc : parentClasses) { if (sc.isPhantom()) { return true; } } return false; }
/** Returns a list of superclasses of c, including itself. */ public List<SootClass> getSuperclassesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); List<SootClass> l = getSuperclassesOf(c); ArrayList<SootClass> al = new ArrayList<SootClass>(); al.add(c); al.addAll(l); return Collections.unmodifiableList(al); }
/** Returns a list of superclasses of c, including itself. */ public List<SootClass> getSuperclassesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); List<SootClass> l = getSuperclassesOf(c); ArrayList<SootClass> al = new ArrayList<SootClass>(); al.add(c); al.addAll(l); return Collections.unmodifiableList(al); }
/** Returns true if child is a subclass of possibleParent. */ public boolean isClassSubclassOf(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); return getSuperclassesOf(child).contains(possibleParent); }
/** Returns true if child is a subclass of possibleParent. */ public boolean isClassSubclassOf(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); return getSuperclassesOf(child).contains(possibleParent); }
/** * Gets all parent classes of the given class. If the given class is an * interface, all parent implementors of this interface are returned. * * @param sc The class or interface for which to get the parents * @return The parents of the given class or interface */ private Set<SootClass> getAllParentClasses(SootClass sc) { List<SootClass> workList = new ArrayList<SootClass>(); workList.add(sc); Set<SootClass> doneSet = new HashSet<SootClass>(); Set<SootClass> classes = new HashSet<>(); while (!workList.isEmpty()) { SootClass curClass = workList.remove(0); if (!doneSet.add(curClass)) continue; if (curClass.isInterface()) { workList.addAll(hierarchy.getSuperinterfacesOf(curClass)); } else { workList.addAll(hierarchy.getSuperclassesOf(curClass)); classes.add(curClass); } } return classes; }
List<SootClass> extendedClasses = Scene.v().getActiveHierarchy().getSuperclassesOf(currentClass); for(SootClass sc : extendedClasses)
for (SootClass parentClass : Scene.v().getActiveHierarchy().getSuperclassesOf(sc)) { if (parentClass.getName().startsWith("android.")) for (SootMethod sm : parentClass.getMethods())
for (SootClass parentClass : Scene.v().getActiveHierarchy().getSuperclassesOf(sootClass)) { if (SystemClassHandler.isClassInSystemPackage(parentClass.getName())) for (SootMethod sm : parentClass.getMethods())