com.ibm.wala.ipa.cha
Interface IClassHierarchy

All Superinterfaces:
java.lang.Iterable<IClass>
All Known Implementing Classes:
ClassHierarchy, CrossLanguageClassHierarchy

public interface IClassHierarchy
extends java.lang.Iterable<IClass>

General interface for a type hierarchy


Method Summary
 boolean addClass(IClass klass)
           
 java.util.Collection<IClass> computeSubClasses(TypeReference type)
          Return set of all subclasses of type in the Class Hierarchy
 ClassLoaderFactory getFactory()
           
 java.util.Collection<IClass> getImmediateSubclasses(IClass klass)
           
 java.util.Set<IClass> getImplementors(TypeReference type)
           
 java.util.Collection<TypeReference> getJavaLangErrorTypes()
          Solely for optimization; return a Collection representing the subclasses of Error kind of ugly.
 java.util.Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
          Solely for optimization; return a Collection representing 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)
           
 java.util.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 type
 java.util.Collection<IMethod> getPossibleTargets(MethodReference ref)
          Find the possible targets of a call to a method reference
 IClass getRootClass()
           
 AnalysisScope getScope()
           
 boolean 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?
 IClass lookupClass(TypeReference A)
          Load a class using one of the loaders specified for this class hierarchy
 IField resolveField(FieldReference f)
           
 IField resolveField(IClass klass, FieldReference f)
           
 IMethod resolveMethod(IClass receiverClass, Selector selector)
          Return the unique receiver of an invocation of method on an object of type declaringClass
 IMethod resolveMethod(MethodReference m)
          Return the unique receiver of an invocation of method on an object of type m.getDeclaredClass
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

getFactory

ClassLoaderFactory getFactory()

getScope

AnalysisScope getScope()

getLoaders

IClassLoader[] getLoaders()

getLoader

IClassLoader getLoader(ClassLoaderReference loaderRef)

addClass

boolean addClass(IClass klass)
Returns:
true if the add succeeded; false if it failed for some reason
Throws:
java.lang.IllegalArgumentException - if klass is null

getNumberOfClasses

int getNumberOfClasses()
Returns:
The number of classes present in the class hierarchy.

isRootClass

boolean isRootClass(IClass c)

getRootClass

IClass getRootClass()

getNumber

int getNumber(IClass c)

getPossibleTargets

java.util.Collection<IMethod> getPossibleTargets(MethodReference ref)
Find the possible targets of a call to a method reference

Parameters:
ref - method reference
Returns:
the set of IMethods that this call can resolve to.
Throws:
java.lang.IllegalArgumentException - if ref is null

getPossibleTargets

java.util.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 type

Parameters:
receiverClass - the class of the receiver
ref - method reference
Returns:
the set of IMethods that this call can resolve to.

resolveMethod

IMethod resolveMethod(MethodReference m)
Return the unique receiver of an invocation of method on an object of type m.getDeclaredClass

Returns:
IMethod, or null if no appropriate receiver is found.
Throws:
java.lang.IllegalArgumentException - if m is null

resolveField

IField resolveField(FieldReference f)
Returns:
the canonical IField that represents a given field , or null if none found
Throws:
java.lang.IllegalArgumentException - if f is null

resolveField

IField resolveField(IClass klass,
                    FieldReference f)
Returns:
the canonical IField that represents a given field , or null if none found
Throws:
java.lang.IllegalArgumentException - if f is null
java.lang.IllegalArgumentException - if klass is null

resolveMethod

IMethod resolveMethod(IClass receiverClass,
                      Selector selector)
Return the unique receiver of an invocation of method on an object of type declaringClass

Parameters:
receiverClass - type of receiver
selector - method signature
Returns:
Method resolved method abstraction
Throws:
java.lang.IllegalArgumentException - if receiverClass is null

lookupClass

IClass lookupClass(TypeReference A)
Load a class using one of the loaders specified for this class hierarchy

Returns:
null if can't find the class.
Throws:
java.lang.IllegalArgumentException - if A is null

isInterface

boolean isInterface(TypeReference type)

getLeastCommonSuperclass

IClass getLeastCommonSuperclass(IClass A,
                                IClass B)

getLeastCommonSuperclass

TypeReference getLeastCommonSuperclass(TypeReference A,
                                       TypeReference B)

isSubclassOf

boolean isSubclassOf(IClass c,
                     IClass T)
Is c a subclass of T?

Throws:
java.lang.IllegalArgumentException - if c is null

implementsInterface

boolean implementsInterface(IClass c,
                            IClass i)
Does c implement i?

Returns:
true iff i is an interface and c is a class that implements i, or c is an interface that extends i.

computeSubClasses

java.util.Collection<IClass> computeSubClasses(TypeReference type)
Return set of all subclasses of type in the Class Hierarchy


getJavaLangErrorTypes

java.util.Collection<TypeReference> getJavaLangErrorTypes()
Solely for optimization; return a Collection representing the subclasses of Error kind of ugly. a better scheme?


getJavaLangRuntimeExceptionTypes

java.util.Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
Solely for optimization; return a Collection representing the subclasses of RuntimeException kind of ugly. a better scheme?


getImplementors

java.util.Set<IClass> getImplementors(TypeReference type)
Parameters:
type - an interface
Returns:
Set of IClass that represent implementors of the interface

getNumberOfImmediateSubclasses

int getNumberOfImmediateSubclasses(IClass klass)
Returns:
the number of classes that immediately extend klass.

getImmediateSubclasses

java.util.Collection<IClass> getImmediateSubclasses(IClass klass)
Returns:
the classes that immediately extend klass.

isAssignableFrom

boolean isAssignableFrom(IClass c1,
                         IClass c2)
Does an expression c1 x := c2 y typecheck? i.e. is c2 a subtype of c1?

Throws:
java.lang.IllegalArgumentException - if c1 is null
java.lang.IllegalArgumentException - if c2 is null