Class CrossLanguageClassHierarchy
java.lang.Object
com.ibm.wala.cast.ipa.cha.CrossLanguageClassHierarchy
- All Implemented Interfaces:
IClassHierarchy, Iterable<IClass>
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.
- Author:
- Julian Dolby (dolby@us.ibm.com)
-
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidClear internal caches that may be invalidated by addition of new classes, e.g., a cache of the results ofIClassHierarchy.getPossibleTargets(MethodReference).Return set of all subclasses of type in the Class HierarchygetImmediateSubclasses(IClass klass) getImplementors(TypeReference type) Solely for optimization; return a Collection<TypeReference> representing the subclasses of ErrorSolely for optimization; return a Collection<TypeReference> representing the subclasses ofRuntimeExceptiongetLoader(ClassLoaderReference loaderRef) intintintgetPossibleTargets(IClass receiverClass, MethodReference ref) Find the possible targets of a call to a method reference where the receiver is of a certain typeFind the possible targets of a call to a method referencegetScope()booleanimplementsInterface(IClass c, IClass i) Does c implement i?booleanisAssignableFrom(IClass c1, IClass c2) Does an expression c1 x := c2 y typecheck?booleanisInterface(TypeReference type) booleanbooleanisSubclassOf(IClass c, IClass T) Is c a subclass of T?iterator()Load a class using one of the loaders specified for this class hierarchystatic CrossLanguageClassHierarchymake(AnalysisScope scope, ClassLoaderFactory factory) resolveField(IClass klass, FieldReference f) resolveMethod(IClass receiver, Selector selector) Return the unique target of an invocation of method on an object of type receiverClassReturn the unique receiver of an invocation of method on an object of typem.getDeclaredClass().Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getFactory
- Specified by:
getFactoryin interfaceIClassHierarchy
-
getScope
- Specified by:
getScopein interfaceIClassHierarchy
-
getLoaders
- Specified by:
getLoadersin interfaceIClassHierarchy
-
getLoader
- Specified by:
getLoaderin interfaceIClassHierarchy
-
addClass
- 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
- Specified by:
isRootClassin interfaceIClassHierarchy
-
getRootClass
- Specified by:
getRootClassin interfaceIClassHierarchy
-
getNumber
- Specified by:
getNumberin interfaceIClassHierarchy
-
getPossibleTargets
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
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
Description copied from interface:IClassHierarchyReturn the unique receiver of an invocation of method on an object of typem.getDeclaredClass(). Note that for Java,m.getDeclaredClass()must represent a class, not an interface. This method does not work for finding inherited methods in interfaces.- Specified by:
resolveMethodin interfaceIClassHierarchy- Returns:
- IMethod, or null if no appropriate receiver is found.
-
resolveField
- Specified by:
resolveFieldin interfaceIClassHierarchy- Returns:
- the canonical IField that represents a given field , or null if none found
-
resolveField
- Specified by:
resolveFieldin interfaceIClassHierarchy- Returns:
- the canonical IField that represents a given field , or null if none found
-
resolveMethod
Description copied from interface:IClassHierarchyReturn the unique target of an invocation of method on an object of type receiverClass- Specified by:
resolveMethodin interfaceIClassHierarchy- Parameters:
receiver- type of receiver. Note that for Java,receiverClassmust represent a class, not an interface. This method does not work for finding inherited methods in interfaces.selector- method signature- Returns:
- Method resolved method abstraction
-
lookupClass
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
- Specified by:
isInterfacein interfaceIClassHierarchy
-
getLeastCommonSuperclass
- Specified by:
getLeastCommonSuperclassin interfaceIClassHierarchy
-
getLeastCommonSuperclass
- Specified by:
getLeastCommonSuperclassin interfaceIClassHierarchy
-
isSubclassOf
Description copied from interface:IClassHierarchyIs c a subclass of T?- Specified by:
isSubclassOfin interfaceIClassHierarchy
-
implementsInterface
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
Description copied from interface:IClassHierarchyReturn set of all subclasses of type in the Class Hierarchy- Specified by:
computeSubClassesin interfaceIClassHierarchy
-
getJavaLangRuntimeExceptionTypes
Description copied from interface:IClassHierarchySolely for optimization; return a Collection<TypeReference> representing the subclasses ofRuntimeExceptionkind of ugly. a better scheme?
- Specified by:
getJavaLangRuntimeExceptionTypesin interfaceIClassHierarchy
-
getJavaLangErrorTypes
Description copied from interface:IClassHierarchySolely for optimization; return a Collection<TypeReference> representing the subclasses of Errorkind of ugly. a better scheme?
- Specified by:
getJavaLangErrorTypesin interfaceIClassHierarchy
-
getImplementors
- Specified by:
getImplementorsin interfaceIClassHierarchy- Parameters:
type- an interface- Returns:
- Set of IClass that represent implementors of the interface
-
getNumberOfImmediateSubclasses
- Specified by:
getNumberOfImmediateSubclassesin interfaceIClassHierarchy- Returns:
- the number of classes that immediately extend klass.
-
getImmediateSubclasses
- Specified by:
getImmediateSubclassesin interfaceIClassHierarchy- Returns:
- the classes that immediately extend klass.
-
isAssignableFrom
Description copied from interface:IClassHierarchyDoes an expression c1 x := c2 y typecheck?i.e. is c2 a subtype of c1?
- Specified by:
isAssignableFromin interfaceIClassHierarchy
-
iterator
-
make
public static CrossLanguageClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory) throws ClassHierarchyException - Throws:
ClassHierarchyException
-
getUnresolvedClasses
- Specified by:
getUnresolvedClassesin interfaceIClassHierarchy
-
clearCaches
public void clearCaches()Description copied from interface:IClassHierarchyClear internal caches that may be invalidated by addition of new classes, e.g., a cache of the results ofIClassHierarchy.getPossibleTargets(MethodReference).- Specified by:
clearCachesin interfaceIClassHierarchy
-