/** * Returns true if child is, or 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 isClassSubclassOfIncluding(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); List<SootClass> parentClasses = getSuperclassesOfIncluding(child); if (parentClasses.contains(possibleParent)) { return true; } for (SootClass sc : parentClasses) { if (sc.isPhantom()) { return true; } } return false; }
private Optional<SootMethod> findAccessibleInSuperClassesBySubSig(SootClass base, String subSig) { Hierarchy hierarchy = Scene.v().getActiveHierarchy(); for (SootClass superClass : hierarchy.getSuperclassesOfIncluding(base.getSuperclass())) { if (superClass.isLibraryClass() && superClass.declaresMethod(subSig)) { SootMethod method = superClass.getMethod(subSig); if (hierarchy.isVisible(base, method)) { return Optional.of(method); } } } return Optional.empty(); } }
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; }
if (!baseType.getSootClass().isInterface()) // the start method we're looking for is NOT an interface method List<SootClass> superClasses = hierarchy.getSuperclassesOfIncluding(baseType.getSootClass()); Iterator<SootClass> it = superClasses.iterator(); while (it.hasNext()) { List<SootClass> superClasses = hierarchy.getSuperclassesOfIncluding(baseType.getSootClass()); Iterator<SootClass> it = superClasses.iterator(); while (it.hasNext()) {
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; }
/** * Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation. */ public SootMethod resolveConcreteDispatch(SootClass concreteType, SootMethod m) { concreteType.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); if (concreteType.isInterface()) { throw new RuntimeException("class needed!"); } String methodSig = m.getSubSignature(); for (SootClass c : getSuperclassesOfIncluding(concreteType)) { SootMethod sm = c.getMethodUnsafe(methodSig); if (sm != null && isVisible(c, m)) { return sm; } } throw new RuntimeException("could not resolve concrete dispatch!\nType: " + concreteType + "\nMethod: " + m); }
List<SootClass> superClasses = hierarchy.getSuperclassesOfIncluding(method.getDeclaringClass()); Iterator<SootClass> it = superClasses.iterator();
SootClass baseTypeClass = ((RefType) pType).getSootClass(); if (!baseTypeClass.isInterface()) { List<SootClass> baseClasses = Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(baseTypeClass); if (!baseClasses.contains(RefType.v("java.lang.Exception").getSootClass())) { for (SootClass baseClass : baseClasses) {
SootClass baseTypeClass = ((RefType) pType).getSootClass(); if (!baseTypeClass.isInterface()) { List<SootClass> baseClasses = Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(baseTypeClass); if (!baseClasses.contains(RefType.v("java.lang.Exception").getSootClass())) { for (SootClass baseClass : baseClasses) {
/** Returns true if child is, or is a subclass of, possibleParent. */ public boolean isClassSubclassOfIncluding(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); return getSuperclassesOfIncluding(child).contains(possibleParent); }
/** Returns true if child is, or is a subclass of, possibleParent. */ public boolean isClassSubclassOfIncluding(SootClass child, SootClass possibleParent) { child.checkLevel(SootClass.HIERARCHY); possibleParent.checkLevel(SootClass.HIERARCHY); return getSuperclassesOfIncluding(child).contains(possibleParent); }
@Override public Collection<SootField> load(SootClass sc) throws Exception { List<SootField> res = new LinkedList<SootField>(); List<SootClass> impler = Scene.v().getActiveHierarchy() .getSuperclassesOfIncluding(method.getDeclaringClass()); for (SootClass c : impler) res.addAll(c.getFields()); return res; } });
/** Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation. */ public SootMethod resolveConcreteDispatch(SootClass concreteType, SootMethod m) { concreteType.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); if (concreteType.isInterface()) throw new RuntimeException("class needed!"); Iterator<SootClass> it = getSuperclassesOfIncluding(concreteType).iterator(); String methodSig = m.getSubSignature(); while (it.hasNext()) { SootClass c = it.next(); if (c.declaresMethod(methodSig) && isVisible( c, m ) ) { return c.getMethod(methodSig); } } throw new RuntimeException("could not resolve concrete dispatch!\nType: "+concreteType+"\nMethod: "+m); }
/** Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation. */ public SootMethod resolveConcreteDispatch(SootClass concreteType, SootMethod m) { concreteType.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); checkState(); if (concreteType.isInterface()) throw new RuntimeException("class needed!"); Iterator<SootClass> it = getSuperclassesOfIncluding(concreteType).iterator(); String methodSig = m.getSubSignature(); while (it.hasNext()) { SootClass c = it.next(); if (c.declaresMethod(methodSig) && isVisible( c, m ) ) { return c.getMethod(methodSig); } } throw new RuntimeException("could not resolve concrete dispatch!\nType: "+concreteType+"\nMethod: "+m); }
List<SootClass> superclasses = Scene.v().getActiveHierarchy().getSuperclassesOfIncluding(parentClass); for (SootClass sclass : superclasses) { MethodWrapType wtClass = getMethodWrapTypeDirect(sclass.getName(), subSig);