Package com.ibm.wala.cast.ipa.cha
Class CrossLanguageClassHierarchy
- java.lang.Object
-
- com.ibm.wala.cast.ipa.cha.CrossLanguageClassHierarchy
-
- All Implemented Interfaces:
IClassHierarchy
,Iterable<IClass>
public class CrossLanguageClassHierarchy extends Object implements IClassHierarchy
This class hierarchy represents a family of disjoint class hierarchies, one for each of a selection of languages. The implementation creates a separate ClassHierarchy object for each language, and this overall IClassHierarchy implementation delegates to the appropriate language class hierarchy based on the language associated with the class loader of the given TypeReference or IClass object. Note that, because of this delegating structure and representation of multiple languages, the getRootClass API call does not make sense for this hierarchy. In general, any code that wants to use multiple language must deal with the fact that there is no longer a single root type. Each individual language is still expected to have a root type, however.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addClass(IClass klass)
Collection<IClass>
computeSubClasses(TypeReference type)
Return set of all subclasses of type in the Class HierarchyClassLoaderFactory
getFactory()
Collection<IClass>
getImmediateSubclasses(IClass klass)
Set<IClass>
getImplementors(TypeReference type)
Collection<TypeReference>
getJavaLangErrorTypes()
Solely for optimization; return a Collectionrepresenting the subclasses of Error kind of ugly. Collection<TypeReference>
getJavaLangRuntimeExceptionTypes()
Solely for optimization; return a Collectionrepresenting the subclasses of RuntimeException
kind of ugly.IClass
getLeastCommonSuperclass(IClass A, IClass B)
TypeReference
getLeastCommonSuperclass(TypeReference A, TypeReference B)
IClassLoader
getLoader(ClassLoaderReference loaderRef)
IClassLoader[]
getLoaders()
int
getNumber(IClass c)
int
getNumberOfClasses()
int
getNumberOfImmediateSubclasses(IClass klass)
Set<IMethod>
getPossibleTargets(IClass receiverClass, MethodReference ref)
Find the possible targets of a call to a method reference where the receiver is of a certain typeSet<IMethod>
getPossibleTargets(MethodReference ref)
Find the possible targets of a call to a method referenceIClass
getRootClass()
AnalysisScope
getScope()
Set<TypeReference>
getUnresolvedClasses()
BEGIN Custom change: unresolved classesboolean
implementsInterface(IClass c, IClass i)
Does c implement i?boolean
isAssignableFrom(IClass c1, IClass c2)
Does an expression c1 x := c2 y typecheck? i.e.boolean
isInterface(TypeReference type)
boolean
isRootClass(IClass c)
boolean
isSubclassOf(IClass c, IClass T)
Is c a subclass of T?Iterator<IClass>
iterator()
IClass
lookupClass(TypeReference A)
Load a class using one of the loaders specified for this class hierarchystatic CrossLanguageClassHierarchy
make(AnalysisScope scope, ClassLoaderFactory factory)
IField
resolveField(IClass klass, FieldReference f)
IField
resolveField(FieldReference f)
IMethod
resolveMethod(IClass receiver, Selector selector)
Return the unique receiver of an invocation of method on an object of type declaringClassIMethod
resolveMethod(MethodReference m)
Return the unique receiver of an invocation of method on an object of type m.getDeclaredClass-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getFactory
public ClassLoaderFactory getFactory()
- Specified by:
getFactory
in interfaceIClassHierarchy
-
getScope
public AnalysisScope getScope()
- Specified by:
getScope
in interfaceIClassHierarchy
-
getLoaders
public IClassLoader[] getLoaders()
- Specified by:
getLoaders
in interfaceIClassHierarchy
-
getLoader
public IClassLoader getLoader(ClassLoaderReference loaderRef)
- Specified by:
getLoader
in interfaceIClassHierarchy
-
addClass
public boolean addClass(IClass klass)
- Specified by:
addClass
in interfaceIClassHierarchy
- Returns:
- true if the add succeeded; false if it failed for some reason
-
getNumberOfClasses
public int getNumberOfClasses()
- Specified by:
getNumberOfClasses
in interfaceIClassHierarchy
- Returns:
- The number of classes present in the class hierarchy.
-
isRootClass
public boolean isRootClass(IClass c)
- Specified by:
isRootClass
in interfaceIClassHierarchy
-
getRootClass
public IClass getRootClass()
- Specified by:
getRootClass
in interfaceIClassHierarchy
-
getNumber
public int getNumber(IClass c)
- Specified by:
getNumber
in interfaceIClassHierarchy
-
getPossibleTargets
public Set<IMethod> getPossibleTargets(MethodReference ref)
Description copied from interface:IClassHierarchy
Find the possible targets of a call to a method reference- Specified by:
getPossibleTargets
in interfaceIClassHierarchy
- Parameters:
ref
- method reference- Returns:
- the set of IMethods that this call can resolve to.
-
getPossibleTargets
public Set<IMethod> getPossibleTargets(IClass receiverClass, MethodReference ref)
Description copied from interface:IClassHierarchy
Find the possible targets of a call to a method reference where the receiver is of a certain type- Specified by:
getPossibleTargets
in interfaceIClassHierarchy
- Parameters:
receiverClass
- the class of the receiverref
- method reference- Returns:
- the set of IMethods that this call can resolve to.
-
resolveMethod
public IMethod resolveMethod(MethodReference m)
Description copied from interface:IClassHierarchy
Return the unique receiver of an invocation of method on an object of type m.getDeclaredClass- Specified by:
resolveMethod
in interfaceIClassHierarchy
- Returns:
- IMethod, or null if no appropriate receiver is found.
-
resolveField
public IField resolveField(FieldReference f)
- Specified by:
resolveField
in interfaceIClassHierarchy
- Returns:
- the canonical IField that represents a given field , or null if none found
-
resolveField
public IField resolveField(IClass klass, FieldReference f)
- Specified by:
resolveField
in interfaceIClassHierarchy
- Returns:
- the canonical IField that represents a given field , or null if none found
-
resolveMethod
public IMethod resolveMethod(IClass receiver, Selector selector)
Description copied from interface:IClassHierarchy
Return the unique receiver of an invocation of method on an object of type declaringClass- Specified by:
resolveMethod
in interfaceIClassHierarchy
- Parameters:
receiver
- type of receiverselector
- method signature- Returns:
- Method resolved method abstraction
-
lookupClass
public IClass lookupClass(TypeReference A)
Description copied from interface:IClassHierarchy
Load a class using one of the loaders specified for this class hierarchy- Specified by:
lookupClass
in interfaceIClassHierarchy
- Returns:
- null if can't find the class.
-
isInterface
public boolean isInterface(TypeReference type)
- Specified by:
isInterface
in interfaceIClassHierarchy
-
getLeastCommonSuperclass
public IClass getLeastCommonSuperclass(IClass A, IClass B)
- Specified by:
getLeastCommonSuperclass
in interfaceIClassHierarchy
-
getLeastCommonSuperclass
public TypeReference getLeastCommonSuperclass(TypeReference A, TypeReference B)
- Specified by:
getLeastCommonSuperclass
in interfaceIClassHierarchy
-
isSubclassOf
public boolean isSubclassOf(IClass c, IClass T)
Description copied from interface:IClassHierarchy
Is c a subclass of T?- Specified by:
isSubclassOf
in interfaceIClassHierarchy
-
implementsInterface
public boolean implementsInterface(IClass c, IClass i)
Description copied from interface:IClassHierarchy
Does c implement i?- Specified by:
implementsInterface
in interfaceIClassHierarchy
- Returns:
- true iff i is an interface and c is a class that implements i, or c is an interface that extends i.
-
computeSubClasses
public Collection<IClass> computeSubClasses(TypeReference type)
Description copied from interface:IClassHierarchy
Return set of all subclasses of type in the Class Hierarchy- Specified by:
computeSubClasses
in interfaceIClassHierarchy
-
getJavaLangRuntimeExceptionTypes
public Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
Description copied from interface:IClassHierarchy
Solely for optimization; return a Collectionrepresenting the subclasses of RuntimeException
kind of ugly. a better scheme?- Specified by:
getJavaLangRuntimeExceptionTypes
in interfaceIClassHierarchy
-
getJavaLangErrorTypes
public Collection<TypeReference> getJavaLangErrorTypes()
Description copied from interface:IClassHierarchy
Solely for optimization; return a Collectionrepresenting the subclasses of Error kind of ugly. a better scheme? - Specified by:
getJavaLangErrorTypes
in interfaceIClassHierarchy
-
getImplementors
public Set<IClass> getImplementors(TypeReference type)
- Specified by:
getImplementors
in interfaceIClassHierarchy
- Parameters:
type
- an interface- Returns:
- Set of IClass that represent implementors of the interface
-
getNumberOfImmediateSubclasses
public int getNumberOfImmediateSubclasses(IClass klass)
- Specified by:
getNumberOfImmediateSubclasses
in interfaceIClassHierarchy
- Returns:
- the number of classes that immediately extend klass.
-
getImmediateSubclasses
public Collection<IClass> getImmediateSubclasses(IClass klass)
- Specified by:
getImmediateSubclasses
in interfaceIClassHierarchy
- Returns:
- the classes that immediately extend klass.
-
isAssignableFrom
public boolean isAssignableFrom(IClass c1, IClass c2)
Description copied from interface:IClassHierarchy
Does an expression c1 x := c2 y typecheck? i.e. is c2 a subtype of c1?- Specified by:
isAssignableFrom
in interfaceIClassHierarchy
-
make
public static CrossLanguageClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory) throws ClassHierarchyException
- Throws:
ClassHierarchyException
-
getUnresolvedClasses
public Set<TypeReference> getUnresolvedClasses()
BEGIN Custom change: unresolved classes- Specified by:
getUnresolvedClasses
in interfaceIClassHierarchy
-
-