Package soot
Class Hierarchy
- java.lang.Object
-
- soot.Hierarchy
-
public class Hierarchy extends Object
Represents the class hierarchy. It is closely linked to a Scene, and must be recreated if the Scene changes. The general convention is that if a method name contains "Including", then it returns the non-strict result; otherwise, it does a strict query (e.g. strict superclass).
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<SootClass,List<SootClass>>classToDirSubclassesprotected Map<SootClass,List<SootClass>>classToSubclassesprotected Map<SootClass,List<SootClass>>interfaceToDirImplementersprotected Map<SootClass,List<SootClass>>interfaceToDirSubinterfacesprotected Map<SootClass,List<SootClass>>interfaceToDirSuperinterfacesprotected Map<SootClass,List<SootClass>>interfaceToSubinterfacesprotected Map<SootClass,List<SootClass>>interfaceToSuperinterfaces
-
Constructor Summary
Constructors Constructor Description Hierarchy()Constructs a hierarchy from the current scene.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckState()List<SootClass>getDirectImplementersOf(SootClass i)Returns a list of direct implementers of c, excluding itself.List<SootClass>getDirectSubclassesOf(SootClass c)Returns a list of direct subclasses of c, excluding c.List<SootClass>getDirectSubclassesOfIncluding(SootClass c)Returns a list of direct subclasses of c, including c.List<SootClass>getDirectSubinterfacesOf(SootClass c)Returns a list of direct subinterfaces of c.List<SootClass>getDirectSubinterfacesOfIncluding(SootClass c)Returns a list of direct subinterfaces of c, including itself.List<SootClass>getDirectSuperclassesOf(SootClass c)Returns a list of direct superclasses of c, excluding c.List<SootClass>getDirectSuperinterfacesOf(SootClass c)Returns a list of direct superinterfaces of c.List<SootClass>getImplementersOf(SootClass i)Returns a list of implementers of c, excluding itself.SootClassgetLeastCommonSuperclassOf(SootClass c1, SootClass c2)Returns the most specific type which is an ancestor of both c1 and c2.List<SootClass>getSubclassesOf(SootClass c)Returns a list of subclasses of c, excluding itself.List<SootClass>getSubclassesOfIncluding(SootClass c)Returns a list of subclasses of c, including itself.List<SootClass>getSubinterfacesOf(SootClass sootClass)Returns a list of subinterfaces of sootClass, excluding itself.List<SootClass>getSubinterfacesOfIncluding(SootClass sootClass)Returns a list of subinterfaces of sootClass, including itself.List<SootClass>getSuperclassesOf(SootClass sootClass)Returns a list of direct superclasses of passed class in reverse order, starting with its parent.List<SootClass>getSuperclassesOfIncluding(SootClass sootClass)Returns a list of superclasses ofsootClass, including itself.List<SootClass>getSuperinterfacesOf(SootClass c)Returns a list of superinterfaces of c, excluding itself.List<SootClass>getSuperinterfacesOfIncluding(SootClass c)Returns a list of superinterfaces of c, including itself.protected voidinitializeHierarchy(Chain<SootClass> allClasses)Initializes the hierarchy given a chain of all classes that shall be included in the hierarchybooleanisClassDirectSubclassOf(SootClass c, SootClass c2)Returns true if child is a direct subclass of possibleParent.booleanisClassSubclassOf(SootClass child, SootClass possibleParent)Returns true if child is a subclass of possibleParent.booleanisClassSubclassOfIncluding(SootClass child, SootClass possibleParent)Returns true if child is, or is a subclass of, possibleParent.booleanisClassSuperclassOf(SootClass parent, SootClass possibleChild)Returns true if child is a superclass of possibleParent.booleanisClassSuperclassOfIncluding(SootClass parent, SootClass possibleChild)Returns true if parent is, or is a superclass of, possibleChild.booleanisInterfaceDirectSubinterfaceOf(SootClass child, SootClass possibleParent)Returns true if child is a direct subinterface of possibleParent.booleanisInterfaceDirectSuperinterfaceOf(SootClass parent, SootClass possibleChild)Returns true if parent is a direct superinterface of possibleChild.booleanisInterfaceSubinterfaceOf(SootClass child, SootClass possibleParent)Returns true if child is a subinterface of possibleParent.booleanisInterfaceSuperinterfaceOf(SootClass parent, SootClass possibleChild)Returns true if parent is a superinterface of possibleChild.booleanisVisible(SootClass from, ClassMember m)Returns true if the classmember m is visible from code in the class from.booleanisVisible(SootClass from, SootClass check)Checks whether check is a visible class in view of the from class.List<SootMethod>resolveAbstractDispatch(List<SootClass> classes, SootMethod m)Returns a list of possible targets for the given method and set of receiver types.List<SootMethod>resolveAbstractDispatch(SootClass c, SootMethod m)Given an abstract dispatch to an object of type c and a method m, gives a list of possible receiver methods.List<SootMethod>resolveConcreteDispatch(List<Type> classes, SootMethod m)Given a set of definite receiver types, returns a list of possible targets.SootMethodresolveConcreteDispatch(SootClass concreteType, SootMethod m)Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation.SootMethodresolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container)Returns the target for the given SpecialInvokeExpr.
-
-
-
Method Detail
-
initializeHierarchy
protected void initializeHierarchy(Chain<SootClass> allClasses)
Initializes the hierarchy given a chain of all classes that shall be included in the hierarchy- Parameters:
allClasses- The chain of all classes to be included in the hierarchy
-
checkState
protected void checkState()
-
getSubclassesOfIncluding
public List<SootClass> getSubclassesOfIncluding(SootClass c)
Returns a list of subclasses of c, including itself.
-
getSubclassesOf
public List<SootClass> getSubclassesOf(SootClass c)
Returns a list of subclasses of c, excluding itself.
-
getSuperclassesOfIncluding
public List<SootClass> getSuperclassesOfIncluding(SootClass sootClass)
Returns a list of superclasses ofsootClass, including itself.- Parameters:
sootClass- the class of which superclasses will be taken. Must not benullor interface- Returns:
- list of superclasses, including itself
- Throws:
IllegalArgumentException- when passed class is an interfaceNullPointerException- when passed argument isnull
-
getSuperclassesOf
public List<SootClass> getSuperclassesOf(SootClass sootClass)
Returns a list of direct superclasses of passed class in reverse order, starting with its parent.- Parameters:
sootClass- the class of which superclasses will be taken. Must not benullor interface- Returns:
- list of superclasses
- Throws:
IllegalArgumentException- when passed class is an interfaceNullPointerException- when passed argument isnull
-
getSubinterfacesOfIncluding
public List<SootClass> getSubinterfacesOfIncluding(SootClass sootClass)
Returns a list of subinterfaces of sootClass, including itself.- Parameters:
sootClass- the interface of which subinterfaces will be taken. Must not benullor class- Returns:
- list of subinterfaces, including passed one
- Throws:
IllegalArgumentException- when passed class is a classNullPointerException- when passed argument isnull
-
getSubinterfacesOf
public List<SootClass> getSubinterfacesOf(SootClass sootClass)
Returns a list of subinterfaces of sootClass, excluding itself.- Parameters:
sootClass- the interface of which subinterfaces will be taken. Must not benullor class- Returns:
- list of subinterfaces, including passed one
- Throws:
IllegalArgumentException- when passed sootClass is a classNullPointerException- when passed argument isnull
-
getSuperinterfacesOfIncluding
public List<SootClass> getSuperinterfacesOfIncluding(SootClass c)
Returns a list of superinterfaces of c, including itself.
-
getSuperinterfacesOf
public List<SootClass> getSuperinterfacesOf(SootClass c)
Returns a list of superinterfaces of c, excluding itself.
-
getDirectSuperclassesOf
public List<SootClass> getDirectSuperclassesOf(SootClass c)
Returns a list of direct superclasses of c, excluding c.
-
getDirectSubclassesOf
public List<SootClass> getDirectSubclassesOf(SootClass c)
Returns a list of direct subclasses of c, excluding c.
-
getDirectSubclassesOfIncluding
public List<SootClass> getDirectSubclassesOfIncluding(SootClass c)
Returns a list of direct subclasses of c, including c.
-
getDirectSuperinterfacesOf
public List<SootClass> getDirectSuperinterfacesOf(SootClass c)
Returns a list of direct superinterfaces of c.
-
getDirectSubinterfacesOf
public List<SootClass> getDirectSubinterfacesOf(SootClass c)
Returns a list of direct subinterfaces of c.
-
getDirectSubinterfacesOfIncluding
public List<SootClass> getDirectSubinterfacesOfIncluding(SootClass c)
Returns a list of direct subinterfaces of c, including itself.
-
getDirectImplementersOf
public List<SootClass> getDirectImplementersOf(SootClass i)
Returns a list of direct implementers of c, excluding itself.
-
getImplementersOf
public List<SootClass> getImplementersOf(SootClass i)
Returns a list of implementers of c, excluding itself.
-
isClassSubclassOf
public boolean isClassSubclassOf(SootClass child, SootClass possibleParent)
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.
-
isClassSubclassOfIncluding
public boolean isClassSubclassOfIncluding(SootClass child, SootClass possibleParent)
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.
-
isClassDirectSubclassOf
public boolean isClassDirectSubclassOf(SootClass c, SootClass c2)
Returns true if child is a direct subclass of possibleParent.
-
isClassSuperclassOf
public boolean isClassSuperclassOf(SootClass parent, SootClass possibleChild)
Returns true if child is a superclass of possibleParent.
-
isClassSuperclassOfIncluding
public boolean isClassSuperclassOfIncluding(SootClass parent, SootClass possibleChild)
Returns true if parent is, or is a superclass of, possibleChild.
-
isInterfaceSubinterfaceOf
public boolean isInterfaceSubinterfaceOf(SootClass child, SootClass possibleParent)
Returns true if child is a subinterface of possibleParent.
-
isInterfaceDirectSubinterfaceOf
public boolean isInterfaceDirectSubinterfaceOf(SootClass child, SootClass possibleParent)
Returns true if child is a direct subinterface of possibleParent.
-
isInterfaceSuperinterfaceOf
public boolean isInterfaceSuperinterfaceOf(SootClass parent, SootClass possibleChild)
Returns true if parent is a superinterface of possibleChild.
-
isInterfaceDirectSuperinterfaceOf
public boolean isInterfaceDirectSuperinterfaceOf(SootClass parent, SootClass possibleChild)
Returns true if parent is a direct superinterface of possibleChild.
-
getLeastCommonSuperclassOf
public SootClass getLeastCommonSuperclassOf(SootClass c1, SootClass c2)
Returns the most specific type which is an ancestor of both c1 and c2.
-
isVisible
public boolean isVisible(SootClass from, SootClass check)
Checks whether check is a visible class in view of the from class. It assumes that protected and private classes do not exit. If they exist and check is either protected or private, the check will return false.
-
isVisible
public boolean isVisible(SootClass from, ClassMember m)
Returns true if the classmember m is visible from code in the class from.
-
resolveConcreteDispatch
public SootMethod resolveConcreteDispatch(SootClass concreteType, SootMethod m)
Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation.
-
resolveConcreteDispatch
public List<SootMethod> resolveConcreteDispatch(List<Type> classes, SootMethod m)
Given a set of definite receiver types, returns a list of possible targets.
-
resolveAbstractDispatch
public List<SootMethod> resolveAbstractDispatch(SootClass c, SootMethod m)
Given an abstract dispatch to an object of type c and a method m, gives a list of possible receiver methods.
-
resolveAbstractDispatch
public List<SootMethod> resolveAbstractDispatch(List<SootClass> classes, SootMethod m)
Returns a list of possible targets for the given method and set of receiver types.
-
resolveSpecialDispatch
public SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container)
Returns the target for the given SpecialInvokeExpr.
-
-