public class ClassHierarchy extends java.lang.Object implements IClassHierarchy
Note that this class hierarchy implementation is mutable. You can add classes via addClass(). You can add a class even if c.getClassLoader() does not appear in getLoaders().
| Modifier and Type | Class and Description |
|---|---|
static class |
ClassHierarchy.MissingSuperClassHandling |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addClass(IClass klass) |
java.util.Collection<IClass> |
computeSubClasses(TypeReference type)
Return set of all subclasses of type in the Class Hierarchy TODO: Tune this implementation.
|
ClassLoaderFactory |
getFactory() |
java.util.Collection<IClass> |
getImmediateSubclasses(IClass klass) |
java.util.Set<IClass> |
getImplementors(TypeReference type)
TODO: tune this if necessary
|
java.util.Collection<TypeReference> |
getJavaLangErrorTypes()
Solely for optimization; return a Collection<TypeReference> representing the subclasses
of Error
|
java.util.Collection<TypeReference> |
getJavaLangRuntimeExceptionTypes()
Solely for optimization; return a Collection<TypeReference> representing the subclasses
of RuntimeException
|
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 declaredClass,
MethodReference ref)
Find the possible receivers of a call to a method reference
|
java.util.Set<IMethod> |
getPossibleTargets(MethodReference ref)
Find the possible targets of a call to a method reference.
|
IClass |
getRootClass() |
AnalysisScope |
getScope() |
ClassHierarchy.MissingSuperClassHandling |
getSuperClassHandling() |
java.util.Set<TypeReference> |
getUnresolvedClasses() |
boolean |
implementsInterface(IClass c,
IClass i)
Does c implement i?
|
boolean |
isAssignableFrom(IClass c1,
IClass c2)
Does an expression c1 x := c2 y typecheck?
|
boolean |
isInterface(TypeReference type) |
boolean |
isRootClass(IClass c) |
boolean |
isSubclassOf(IClass c,
IClass t)
Is c a subclass of T?
|
java.util.Iterator<IClass> |
iterator() |
IClass |
lookupClass(TypeReference a)
Find a class in this class hierarchy.
|
IField |
resolveField(FieldReference f) |
IField |
resolveField(IClass klass,
FieldReference f) |
IMethod |
resolveMethod(IClass receiverClass,
Selector selector)
Return the unique target 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
|
java.lang.String |
toString() |
public boolean addClass(IClass klass)
addClass in interface IClassHierarchyjava.lang.IllegalArgumentException - if klass is nullpublic java.util.Set<IMethod> getPossibleTargets(MethodReference ref)
getPossibleTargets in interface IClassHierarchyref - method referencejava.lang.IllegalArgumentException - if ref is nullpublic java.util.Set<IMethod> getPossibleTargets(IClass declaredClass, MethodReference ref)
getPossibleTargets in interface IClassHierarchyref - method referencedeclaredClass - the class of the receiverpublic IMethod resolveMethod(MethodReference m)
resolveMethod in interface IClassHierarchyjava.lang.IllegalArgumentException - if m is nullpublic IField resolveField(FieldReference f)
resolveField in interface IClassHierarchyjava.lang.IllegalArgumentException - if f is nullpublic IField resolveField(IClass klass, FieldReference f)
resolveField in interface IClassHierarchyjava.lang.IllegalArgumentException - if f is nulljava.lang.IllegalArgumentException - if klass is nullpublic IMethod resolveMethod(IClass receiverClass, Selector selector)
resolveMethod in interface IClassHierarchyreceiverClass - type of receiverselector - method signaturejava.lang.IllegalArgumentException - if receiverClass is nullpublic java.lang.String toString()
toString in class java.lang.Objectpublic ClassLoaderFactory getFactory()
getFactory in interface IClassHierarchypublic IClass getLeastCommonSuperclass(IClass a, IClass b)
getLeastCommonSuperclass in interface IClassHierarchyjava.lang.IllegalArgumentException - if A is nullpublic TypeReference getLeastCommonSuperclass(TypeReference a, TypeReference b)
getLeastCommonSuperclass in interface IClassHierarchypublic IClass lookupClass(TypeReference a)
lookupClass in interface IClassHierarchyIClass for a if found; null if can't find the class.java.lang.IllegalArgumentException - if A is nullpublic boolean isSubclassOf(IClass c, IClass t)
isSubclassOf in interface IClassHierarchyjava.lang.IllegalArgumentException - if c is nullpublic boolean implementsInterface(IClass c, IClass i)
implementsInterface in interface IClassHierarchypublic java.util.Collection<IClass> computeSubClasses(TypeReference type)
computeSubClasses in interface IClassHierarchypublic java.util.Collection<TypeReference> getJavaLangErrorTypes()
kind of ugly. a better scheme?
getJavaLangErrorTypes in interface IClassHierarchypublic java.util.Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
kind of ugly. a better scheme?
getJavaLangRuntimeExceptionTypes in interface IClassHierarchypublic boolean isInterface(TypeReference type)
isInterface in interface IClassHierarchypublic java.util.Set<IClass> getImplementors(TypeReference type)
getImplementors in interface IClassHierarchytype - an interfacepublic java.util.Iterator<IClass> iterator()
iterator in interface java.lang.Iterable<IClass>public int getNumberOfClasses()
getNumberOfClasses in interface IClassHierarchypublic IClassLoader[] getLoaders()
getLoaders in interface IClassHierarchypublic IClassLoader getLoader(ClassLoaderReference loaderRef)
getLoader in interface IClassHierarchypublic AnalysisScope getScope()
getScope in interface IClassHierarchypublic int getNumberOfImmediateSubclasses(IClass klass)
getNumberOfImmediateSubclasses in interface IClassHierarchypublic java.util.Collection<IClass> getImmediateSubclasses(IClass klass)
getImmediateSubclasses in interface IClassHierarchypublic IClass getRootClass()
getRootClass in interface IClassHierarchypublic boolean isRootClass(IClass c) throws java.lang.IllegalArgumentException
isRootClass in interface IClassHierarchyjava.lang.IllegalArgumentExceptionpublic int getNumber(IClass c)
getNumber in interface IClassHierarchypublic boolean isAssignableFrom(IClass c1, IClass c2)
i.e. is c2 a subtype of c1?
isAssignableFrom in interface IClassHierarchyjava.lang.IllegalArgumentException - if c1 is nulljava.lang.IllegalArgumentException - if c2 is nullpublic final java.util.Set<TypeReference> getUnresolvedClasses()
getUnresolvedClasses in interface IClassHierarchypublic ClassHierarchy.MissingSuperClassHandling getSuperClassHandling()