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 booleanaddClass(IClass klass)Collection<IClass>computeSubClasses(TypeReference type)Return set of all subclasses of type in the Class HierarchyClassLoaderFactorygetFactory()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 RuntimeExceptionkind of ugly.IClassgetLeastCommonSuperclass(IClass A, IClass B)TypeReferencegetLeastCommonSuperclass(TypeReference A, TypeReference B)IClassLoadergetLoader(ClassLoaderReference loaderRef)IClassLoader[]getLoaders()intgetNumber(IClass c)intgetNumberOfClasses()intgetNumberOfImmediateSubclasses(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 referenceIClassgetRootClass()AnalysisScopegetScope()Set<TypeReference>getUnresolvedClasses()BEGIN Custom change: unresolved classesbooleanimplementsInterface(IClass c, IClass i)Does c implement i?booleanisAssignableFrom(IClass c1, IClass c2)Does an expression c1 x := c2 y typecheck? i.e.booleanisInterface(TypeReference type)booleanisRootClass(IClass c)booleanisSubclassOf(IClass c, IClass T)Is c a subclass of T?Iterator<IClass>iterator()IClasslookupClass(TypeReference A)Load a class using one of the loaders specified for this class hierarchystatic CrossLanguageClassHierarchymake(AnalysisScope scope, ClassLoaderFactory factory)IFieldresolveField(IClass klass, FieldReference f)IFieldresolveField(FieldReference f)IMethodresolveMethod(IClass receiver, Selector selector)Return the unique receiver of an invocation of method on an object of type declaringClassIMethodresolveMethod(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:
getFactoryin interfaceIClassHierarchy
-
getScope
public AnalysisScope getScope()
- Specified by:
getScopein interfaceIClassHierarchy
-
getLoaders
public IClassLoader[] getLoaders()
- Specified by:
getLoadersin interfaceIClassHierarchy
-
getLoader
public IClassLoader getLoader(ClassLoaderReference loaderRef)
- Specified by:
getLoaderin interfaceIClassHierarchy
-
addClass
public boolean addClass(IClass klass)
- Specified by:
addClassin interfaceIClassHierarchy- Returns:
- true if the add succeeded; false if it failed for some reason
-
getNumberOfClasses
public int getNumberOfClasses()
- Specified by:
getNumberOfClassesin interfaceIClassHierarchy- Returns:
- The number of classes present in the class hierarchy.
-
isRootClass
public boolean isRootClass(IClass c)
- Specified by:
isRootClassin interfaceIClassHierarchy
-
getRootClass
public IClass getRootClass()
- Specified by:
getRootClassin interfaceIClassHierarchy
-
getNumber
public int getNumber(IClass c)
- Specified by:
getNumberin interfaceIClassHierarchy
-
getPossibleTargets
public Set<IMethod> getPossibleTargets(MethodReference ref)
Description copied from interface:IClassHierarchyFind the possible targets of a call to a method reference- Specified by:
getPossibleTargetsin 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:IClassHierarchyFind the possible targets of a call to a method reference where the receiver is of a certain type- Specified by:
getPossibleTargetsin 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:IClassHierarchyReturn the unique receiver of an invocation of method on an object of type m.getDeclaredClass- Specified by:
resolveMethodin interfaceIClassHierarchy- Returns:
- IMethod, or null if no appropriate receiver is found.
-
resolveField
public IField resolveField(FieldReference f)
- Specified by:
resolveFieldin 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:
resolveFieldin 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:IClassHierarchyReturn the unique receiver of an invocation of method on an object of type declaringClass- Specified by:
resolveMethodin interfaceIClassHierarchy- Parameters:
receiver- type of receiverselector- method signature- Returns:
- Method resolved method abstraction
-
lookupClass
public IClass lookupClass(TypeReference A)
Description copied from interface:IClassHierarchyLoad a class using one of the loaders specified for this class hierarchy- Specified by:
lookupClassin interfaceIClassHierarchy- Returns:
- null if can't find the class.
-
isInterface
public boolean isInterface(TypeReference type)
- Specified by:
isInterfacein interfaceIClassHierarchy
-
getLeastCommonSuperclass
public IClass getLeastCommonSuperclass(IClass A, IClass B)
- Specified by:
getLeastCommonSuperclassin interfaceIClassHierarchy
-
getLeastCommonSuperclass
public TypeReference getLeastCommonSuperclass(TypeReference A, TypeReference B)
- Specified by:
getLeastCommonSuperclassin interfaceIClassHierarchy
-
isSubclassOf
public boolean isSubclassOf(IClass c, IClass T)
Description copied from interface:IClassHierarchyIs c a subclass of T?- Specified by:
isSubclassOfin interfaceIClassHierarchy
-
implementsInterface
public boolean implementsInterface(IClass c, IClass i)
Description copied from interface:IClassHierarchyDoes c implement i?- Specified by:
implementsInterfacein 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:IClassHierarchyReturn set of all subclasses of type in the Class Hierarchy- Specified by:
computeSubClassesin interfaceIClassHierarchy
-
getJavaLangRuntimeExceptionTypes
public Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
Description copied from interface:IClassHierarchySolely for optimization; return a Collectionrepresenting the subclasses of RuntimeExceptionkind of ugly. a better scheme?- Specified by:
getJavaLangRuntimeExceptionTypesin interfaceIClassHierarchy
-
getJavaLangErrorTypes
public Collection<TypeReference> getJavaLangErrorTypes()
Description copied from interface:IClassHierarchySolely for optimization; return a Collectionrepresenting the subclasses of Error kind of ugly. a better scheme? - Specified by:
getJavaLangErrorTypesin interfaceIClassHierarchy
-
getImplementors
public Set<IClass> getImplementors(TypeReference type)
- Specified by:
getImplementorsin interfaceIClassHierarchy- Parameters:
type- an interface- Returns:
- Set of IClass that represent implementors of the interface
-
getNumberOfImmediateSubclasses
public int getNumberOfImmediateSubclasses(IClass klass)
- Specified by:
getNumberOfImmediateSubclassesin interfaceIClassHierarchy- Returns:
- the number of classes that immediately extend klass.
-
getImmediateSubclasses
public Collection<IClass> getImmediateSubclasses(IClass klass)
- Specified by:
getImmediateSubclassesin interfaceIClassHierarchy- Returns:
- the classes that immediately extend klass.
-
isAssignableFrom
public boolean isAssignableFrom(IClass c1, IClass c2)
Description copied from interface:IClassHierarchyDoes an expression c1 x := c2 y typecheck? i.e. is c2 a subtype of c1?- Specified by:
isAssignableFromin 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:
getUnresolvedClassesin interfaceIClassHierarchy
-
-