soot
Class FastHierarchy

java.lang.Object
  |
  +--soot.FastHierarchy

public class FastHierarchy
extends java.lang.Object

Represents the class hierarchy. It is closely linked to a Scene, and must be recreated if the Scene changes. This version supercedes the old soot.Hierarchy class.


Inner Class Summary
protected  class FastHierarchy.Interval
           
 
Field Summary
protected  java.util.Map 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  java.util.Map classToSubclasses
          This map holds all key,value pairs such that value.getSuperclass() == key.
protected  MultiMap interfaceToAllImplementers
          This map gives, for an interface, all concrete classes that implement that interface and all its subinterfaces, but NOT their subclasses.
protected  MultiMap interfaceToAllSubinterfaces
          This map is a transitive closure of interfaceToSubinterfaces, and each set contains its superinterface itself.
protected  MultiMap 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 interfaceToSubinterfaces
          This map holds all key,value pairs such that value is an interface and key is in value.getInterfaces().
protected  Scene sc
          These maps cache subtype queries, so they can be re-done quickly.
 
Constructor Summary
FastHierarchy()
          Constructs a hierarchy from the current scene.
 
Method Summary
protected  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.
 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.
protected  int dfsVisit(int start, SootClass c)
           
 java.util.Set getAllImplementersOfInterface(SootClass parent)
          For an interface parent (MUST be an interface), returns set of all implementers of it but NOT their subclasses.
protected  java.util.Set getAllSubinterfaces(SootClass parent)
          For an interface parent (MUST be an interface), returns set of all subinterfaces.
 java.util.Collection getSubclassesOf(SootClass c)
           
protected  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.
 java.util.Set resolveAbstractDispatch(SootClass abstractType, SootMethod m)
          Given an object of declared type C, returns the methods which could be called on an o.f() invocation.
 java.util.Collection resolveConcreteDispatch(java.util.Collection concreteTypes, SootMethod m, RefType declaredTypeOfBase)
           
 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.
 java.util.Collection resolveConcreteDispatchWithoutFailing(java.util.Collection concreteTypes, SootMethod m, RefType declaredTypeOfBase)
           
 SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie, SootMethod container)
          Returns the target for the given SpecialInvokeExpr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classToSubclasses

protected java.util.Map classToSubclasses
This map holds all key,value pairs such that value.getSuperclass() == key. This is one of the three maps that hold the inverse of the relationships given by the getSuperclass and getInterfaces methods of SootClass.

interfaceToSubinterfaces

protected MultiMap interfaceToSubinterfaces
This map holds all key,value pairs such that value is an interface and key is in value.getInterfaces(). This is one of the three maps that hold the inverse of the relationships given by the getSuperclass and getInterfaces methods of SootClass.

interfaceToImplementers

protected MultiMap interfaceToImplementers
This map holds all key,value pairs such that value is a class (NOT an interface) and key is in value.getInterfaces(). This is one of the three maps that hold the inverse of the relationships given by the getSuperclass and getInterfaces methods of SootClass.

interfaceToAllSubinterfaces

protected MultiMap interfaceToAllSubinterfaces
This map is a transitive closure of interfaceToSubinterfaces, and each set contains its superinterface itself.

interfaceToAllImplementers

protected MultiMap interfaceToAllImplementers
This map gives, for an interface, all concrete classes that implement that interface and all its subinterfaces, but NOT their subclasses.

classToInterval

protected java.util.Map 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.

sc

protected Scene sc
These maps cache subtype queries, so they can be re-done quickly.
Constructor Detail

FastHierarchy

public FastHierarchy()
Constructs a hierarchy from the current scene.
Method Detail

dfsVisit

protected int dfsVisit(int start,
                       SootClass c)

isSubclass

protected 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.

getAllImplementersOfInterface

public java.util.Set getAllImplementersOfInterface(SootClass parent)
For an interface parent (MUST be an interface), returns set of all implementers of it but NOT their subclasses.

getAllSubinterfaces

protected java.util.Set getAllSubinterfaces(SootClass parent)
For an interface parent (MUST be an interface), returns set of all subinterfaces.

canStoreType

public 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. If child is an interface that is not a subinterface of parent, this method will return false even though some objects implementing the child interface may also implement the parent interface.

canStoreClass

protected 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. If child is an interface that is not a subinterface of parent, this method will return false even though some objects implementing the child interface may also implement the parent interface.

resolveConcreteDispatchWithoutFailing

public java.util.Collection resolveConcreteDispatchWithoutFailing(java.util.Collection concreteTypes,
                                                                  SootMethod m,
                                                                  RefType declaredTypeOfBase)

resolveConcreteDispatch

public java.util.Collection resolveConcreteDispatch(java.util.Collection concreteTypes,
                                                    SootMethod m,
                                                    RefType declaredTypeOfBase)

resolveAbstractDispatch

public java.util.Set resolveAbstractDispatch(SootClass abstractType,
                                             SootMethod m)
Given an object of declared type C, returns the methods which could be called on an o.f() invocation.

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.

resolveSpecialDispatch

public SootMethod resolveSpecialDispatch(SpecialInvokeExpr ie,
                                         SootMethod container)
Returns the target for the given SpecialInvokeExpr.

getSubclassesOf

public java.util.Collection getSubclassesOf(SootClass c)