/** Returns a list of superinterfaces of c, including itself. */ public List<SootClass> getSuperinterfacesOfIncluding(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (!c.isInterface()) { throw new RuntimeException("interface needed!"); } List<SootClass> l = new ArrayList<SootClass>(); l.addAll(getSuperinterfacesOf(c)); l.add(c); return Collections.unmodifiableList(l); }
/** Returns true if parent is a superinterface of possibleChild. */ public boolean isInterfaceSuperinterfaceOf(SootClass parent, SootClass possibleChild) { parent.checkLevel(SootClass.HIERARCHY); possibleChild.checkLevel(SootClass.HIERARCHY); return getSuperinterfacesOf(possibleChild).contains(parent); }
/** * 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; }