public class FastHierarchy extends Object
This version supercedes the old soot.Hierarchy class.
| Modifier and Type | Class and Description |
|---|---|
protected class |
FastHierarchy.Interval |
| Modifier and Type | Field and Description |
|---|---|
protected RefType |
cilArray |
protected RefType |
cilIcomparable |
protected RefType |
cilIcomparable1 |
protected RefType |
cilIconvertible |
protected RefType |
cilIequatable1 |
protected RefType |
cilIformattable |
protected Map<SootClass,FastHierarchy.Interval> |
classToInterval
For each class (NOT interface), this map contains a Interval, which is a pair of numbers giving a preorder and postorder
ordering of classes in the inheritance tree.
|
protected MultiMap<SootClass,SootClass> |
classToSubclasses
This map holds all key,value pairs such that value.getSuperclass() == key.
|
protected MultiMap<SootClass,SootClass> |
interfaceToAllImplementers
This map gives, for an interface, all concrete classes that implement that interface and all its subinterfaces, but NOT
their subclasses.
|
protected MultiMap<SootClass,SootClass> |
interfaceToAllSubinterfaces
This map is a transitive closure of interfaceToSubinterfaces, and each set contains its superinterface itself.
|
protected MultiMap<SootClass,SootClass> |
interfaceToImplementers
This map holds all key,value pairs such that value is a class (NOT an interface) and key is in value.getInterfaces().
|
protected MultiMap<SootClass,SootClass> |
interfaceToSubinterfaces
This map holds all key,value pairs such that value is an interface and key is in value.getInterfaces().
|
protected RefType |
rtCloneable |
protected RefType |
rtObject |
protected RefType |
rtSerializable |
protected Scene |
sc |
protected com.google.common.collect.Table<SootClass,NumberedString,SootMethod> |
typeToVtbl |
protected static int |
USE_INTERVALS_BOUNDARY |
| Constructor and Description |
|---|
FastHierarchy()
Constructs a hierarchy from the current scene.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
buildInverseMaps() |
boolean |
canStoreClass(SootClass child,
SootClass parent)
Given an object of declared type child, returns true if the object can be stored in a variable of type parent.
|
protected boolean |
canStoreClassClassic(SootClass child,
SootClass parent)
"Classic" implementation using the intuitive approach (without using
FastHierarchy.Interval) to check whether
child can be stored in a type of parent: |
boolean |
canStoreType(Type child,
Type parent)
Given an object of declared type child, returns true if the object can be stored in a variable of type parent.
|
Iterable<Type> |
canStoreTypeList(Type nt)
Returns a list of types which can be used to store the given type
|
protected int |
dfsVisit(int start,
SootClass c) |
Set<SootClass> |
getAllImplementersOfInterface(SootClass parent)
For an interface parent (MUST be an interface), returns set of all implementers of it but NOT their subclasses.
|
Set<SootClass> |
getAllSubinterfaces(SootClass parent)
For an interface parent (MUST be an interface), returns set of all subinterfaces including
parent. |
Collection<SootClass> |
getSubclassesOf(SootClass c)
Gets the direct subclasses of a given class.
|
protected boolean |
isHandleDefaultMethods() |
boolean |
isSubclass(SootClass child,
SootClass parent)
Return true if class child is a subclass of class parent, neither of them being allowed to be interfaces.
|
Set<SootMethod> |
resolveAbstractDispatch(SootClass baseType,
SootMethod m)
Given an object of declared type C, returns the methods which could be called on an o.f() invocation.
|
Set<SootMethod> |
resolveAbstractDispatch(SootClass baseType,
SootMethodRef m)
Given an object of declared type C, returns the methods which could be called on an o.f() invocation.
|
Collection<SootMethod> |
resolveConcreteDispatch(Collection<Type> concreteTypes,
SootMethod m,
RefType declaredTypeOfBase) |
SootMethod |
resolveConcreteDispatch(SootClass baseType,
SootMethod m)
Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation.
|
SootMethod |
resolveConcreteDispatch(SootClass baseType,
SootMethodRef m)
Given an object of actual type C (o = new C()), returns the method which will be called on an o.f() invocation.
|
Collection<SootMethod> |
resolveConcreteDispatchWithoutFailing(Collection<Type> concreteTypes,
SootMethod m,
RefType declaredTypeOfBase) |
SootMethod |
resolveMethod(SootClass baseType,
SootClass declaringClass,
String name,
List<Type> parameterTypes,
Type returnType,
boolean allowAbstract)
Conducts the actual dispatch by searching up the baseType's superclass hierarchy and interface hierarchy if the
sourcecode level is beyond Java 7 (due to default interface methods.) Given an object of actual type C (o = new C()),
returns the method which will be called on an o.f() invocation.
|
SootMethod |
resolveMethod(SootClass baseType,
SootClass declaringClass,
String name,
List<Type> parameterTypes,
Type returnType,
boolean allowAbstract,
NumberedString subsignature)
Conducts the actual dispatch by searching up the baseType's superclass hierarchy and interface hierarchy if the
sourcecode level is beyond Java 7 (due to default interface methods.) Given an object of actual type C (o = new C()),
returns the method which will be called on an o.f() invocation.
|
SootMethod |
resolveMethod(SootClass baseType,
SootMethod m,
boolean allowAbstract)
Conducts the actual dispatch by searching up the baseType's superclass hierarchy and interface hierarchy if the
sourcecode level is beyond Java 7 (due to default interface methods.) Given an object of actual type C (o = new C()),
returns the method which will be called on an o.f() invocation.
|
SootMethod |
resolveMethod(SootClass baseType,
SootMethodRef m,
boolean allowAbstract)
Conducts the actual dispatch by searching up the baseType's superclass hierarchy and interface hierarchy if the
sourcecode level is beyond Java 7 (due to default interface methods.) Given an object of actual type C (o = new C()),
returns the method which will be called on an o.f() invocation.
|
SootMethod |
resolveSpecialDispatch(SootMethod callee,
SootMethod container)
Returns the target for the given SpecialInvokeExpr.
|
protected static final int USE_INTERVALS_BOUNDARY
protected com.google.common.collect.Table<SootClass,NumberedString,SootMethod> typeToVtbl
protected MultiMap<SootClass,SootClass> classToSubclasses
protected MultiMap<SootClass,SootClass> interfaceToSubinterfaces
protected MultiMap<SootClass,SootClass> interfaceToImplementers
protected MultiMap<SootClass,SootClass> interfaceToAllSubinterfaces
protected MultiMap<SootClass,SootClass> interfaceToAllImplementers
protected Map<SootClass,FastHierarchy.Interval> classToInterval
protected final Scene sc
protected final RefType rtObject
protected final RefType rtSerializable
protected final RefType rtCloneable
protected final RefType cilArray
protected final RefType cilIcomparable1
protected final RefType cilIcomparable
protected final RefType cilIconvertible
protected final RefType cilIequatable1
protected final RefType cilIformattable
public FastHierarchy()
protected int dfsVisit(int start,
SootClass c)
protected void buildInverseMaps()
public boolean isSubclass(SootClass child, SootClass parent)
public Set<SootClass> getAllImplementersOfInterface(SootClass parent)
This method can be used concurrently (is thread safe).
parent - the parent interface.public Set<SootClass> getAllSubinterfaces(SootClass parent)
parent.
This method can be used concurrently (is thread safe).
parent - the parent interface.public boolean canStoreType(Type child, Type parent)
public boolean canStoreClass(SootClass child, SootClass parent)
protected boolean canStoreClassClassic(SootClass child, SootClass parent)
FastHierarchy.Interval) to check whether
child can be stored in a type of parent:
If parent is not an interface we simply traverse and check the super-classes of child.
If parent is an interface we traverse the super-classes of child and check each interface
implemented by this class. Also each interface is checked recursively for super interfaces it implements.
This implementation can be much faster (compared to the interval based implementation of
canStoreClass(SootClass, SootClass) in cases where one interface is implemented in thousands of classes.
child - parent - public Collection<SootMethod> resolveConcreteDispatchWithoutFailing(Collection<Type> concreteTypes, SootMethod m, RefType declaredTypeOfBase)
public Collection<SootMethod> resolveConcreteDispatch(Collection<Type> concreteTypes, SootMethod m, RefType declaredTypeOfBase)
public Set<SootMethod> resolveAbstractDispatch(SootClass baseType, SootMethod m)
baseType - The declared type Cpublic Set<SootMethod> resolveAbstractDispatch(SootClass baseType, SootMethodRef m)
baseType - The declared type Cpublic SootMethod resolveConcreteDispatch(SootClass baseType, SootMethod m)
baseType - The actual type Cpublic SootMethod resolveConcreteDispatch(SootClass baseType, SootMethodRef m)
baseType - The actual type Cpublic SootMethod resolveMethod(SootClass baseType, SootMethod m, boolean allowAbstract)
If abstract methods are allowed, it will just resolve to the first method found according to javas method resolution process: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3
baseType - The type Cm - The method f to resolvepublic SootMethod resolveMethod(SootClass baseType, SootMethodRef m, boolean allowAbstract)
If abstract methods are allowed, it will just resolve to the first method found according to javas method resolution process: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3
baseType - The type Cm - The method f to resolvepublic SootMethod resolveMethod(SootClass baseType, SootClass declaringClass, String name, List<Type> parameterTypes, Type returnType, boolean allowAbstract)
If abstract methods are allowed, it will just resolve to the first method found according to javas method resolution process: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3
baseType - The type CdeclaringClass - declaring class of the method to resolvename - Name of the method to resolvepublic SootMethod resolveMethod(SootClass baseType, SootClass declaringClass, String name, List<Type> parameterTypes, Type returnType, boolean allowAbstract, NumberedString subsignature)
If abstract methods are allowed, it will just resolve to the first method found according to javas method resolution process: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3
baseType - The type CdeclaringClass - declaring class of the method to resolvename - Name of the method to resolvesubsignature - The subsignature (can be null) to speed up the resolving process.protected boolean isHandleDefaultMethods()
public SootMethod resolveSpecialDispatch(SootMethod callee, SootMethod container)
public Collection<SootClass> getSubclassesOf(SootClass c)
c - the classCopyright © 2024 Soot OSS. All rights reserved.