/** Returns a list of superinterfaces of c, excluding itself. */ public List<SootClass> getSuperinterfacesOf(SootClass c) { c.checkLevel(SootClass.HIERARCHY); if (!c.isInterface()) { throw new RuntimeException("interface needed!"); } checkState(); // If already cached, return the value. List<SootClass> cached = interfaceToSuperinterfaces.get(c); if (cached != null) { return cached; } // Otherwise, build up the hashmap. List<SootClass> l = new ArrayList<SootClass>(); for (SootClass si : interfaceToDirSuperinterfaces.get(c)) { l.addAll(getSuperinterfacesOfIncluding(si)); } interfaceToSuperinterfaces.put(c, Collections.unmodifiableList(l)); return Collections.unmodifiableList(l); }
private Set<SootClass> getParentsOfIncluding(Collection<SootClass> classes) { final Set<SootClass> parents = new HashSet<>(classes); for (SootClass clazz : classes) { // add implementing interfaces parents.addAll(clazz.getInterfaces()); // add extending class if any if (!clazz.isInterface() && clazz.hasSuperclass()) { parents.add(clazz.getSuperclass()); } // and superclasses (superinterfaces) of passed applicationClass parents.addAll(clazz.isInterface() ? Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(clazz) : Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(clazz)); } return parents; }
private List<SootClass> getParentsOfIncluding(SootClass applicationClass) { // result contains of interfaces that implements passed applicationClass final List<SootClass> result = HierarchyUtils.getAllInterfacesOf(applicationClass); // add implementing interfaces result.addAll(applicationClass.getInterfaces()); // add extending class if any if (!applicationClass.isInterface() && applicationClass.hasSuperclass()) { result.add(applicationClass.getSuperclass()); } // and superclasses (superinterfaces) of passed applicationClass result.addAll( applicationClass.isInterface() ? Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(applicationClass) : Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(applicationClass)); return result; }
/** * Checks whether the taint wrapper has been configured for the given method in * the given interface or one of its parent interfaces. * * @param subSig * The method subsignature to look for * @param ifc * The interface where to start the search * @return The configured type of wrapping if the given method is implemented in * the given interface or one of its super interfaces, otherwise * NotRegistered */ private MethodWrapType getInterfaceWrapType(String subSig, SootClass ifc) { if (ifc.isPhantom()) return getMethodWrapTypeDirect(ifc.getName(), subSig); assert ifc.isInterface() : "Class " + ifc.getName() + " is not an interface, though returned " + "by getInterfaces()."; for (SootClass pifc : Scene.v().getActiveHierarchy().getSuperinterfacesOfIncluding(ifc)) { MethodWrapType wt = getMethodWrapTypeDirect(pifc.getName(), subSig); if (wt != MethodWrapType.NotRegistered) return wt; } return MethodWrapType.NotRegistered; }