public class ClassHierarchy extends Object implements IClassHierarchy
Modifier and Type | Method and Description |
---|---|
boolean |
addClass(IClass klass) |
Collection<IClass> |
computeSubClasses(TypeReference type)
Return set of all subclasses of type in the Class Hierarchy TODO: Tune this implementation.
|
ClassLoaderFactory |
getFactory() |
Collection<IClass> |
getImmediateSubclasses(IClass klass) |
Set<IClass> |
getImplementors(TypeReference type)
TODO: tune this if necessary
|
Collection<TypeReference> |
getJavaLangErrorTypes()
Solely for optimization; return a Collection
|
Collection<TypeReference> |
getJavaLangRuntimeExceptionTypes()
Solely for optimization; return a Collection
|
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 declaredClass,
MethodReference ref)
Find the possible receivers of a call to a method reference
|
Set<IMethod> |
getPossibleTargets(MethodReference ref)
Find the possible targets of a call to a method reference.
|
IClass |
getRootClass() |
AnalysisScope |
getScope() |
Set<TypeReference> |
getUnresolvedClasses()
BEGIN Custom change: remember unresolved classes
|
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?
|
Iterator<IClass> |
iterator() |
IClass |
lookupClass(TypeReference a)
Find a class in this class hierarchy.
|
static ClassHierarchy |
make(AnalysisScope scope) |
static ClassHierarchy |
make(AnalysisScope scope,
ClassLoaderFactory factory) |
static ClassHierarchy |
make(AnalysisScope scope,
ClassLoaderFactory factory,
Language language) |
static ClassHierarchy |
make(AnalysisScope scope,
ClassLoaderFactory factory,
Language language,
MonitorUtil.IProgressMonitor monitor)
temporarily marking this internal to avoid infinite sleep with randomly chosen IProgressMonitor.
|
static ClassHierarchy |
make(AnalysisScope scope,
ClassLoaderFactory factory,
MonitorUtil.IProgressMonitor monitor)
temporarily marking this internal to avoid infinite sleep with randomly chosen IProgressMonitor.
|
static ClassHierarchy |
make(AnalysisScope scope,
ClassLoaderFactory factory,
Set<Language> languages) |
static ClassHierarchy |
make(AnalysisScope scope,
MonitorUtil.IProgressMonitor monitor)
temporarily marking this internal to avoid infinite sleep with randomly chosen IProgressMonitor.
|
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
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public boolean addClass(IClass klass)
addClass
in interface IClassHierarchy
IllegalArgumentException
- if klass is nullpublic Set<IMethod> getPossibleTargets(MethodReference ref)
getPossibleTargets
in interface IClassHierarchy
ref
- method referenceIllegalArgumentException
- if ref is nullpublic Set<IMethod> getPossibleTargets(IClass declaredClass, MethodReference ref)
getPossibleTargets
in interface IClassHierarchy
ref
- method referencedeclaredClass
- the class of the receiverpublic IMethod resolveMethod(MethodReference m)
resolveMethod
in interface IClassHierarchy
m
- IllegalArgumentException
- if m is nullpublic IField resolveField(FieldReference f)
resolveField
in interface IClassHierarchy
IllegalArgumentException
- if f is nullpublic IField resolveField(IClass klass, FieldReference f)
resolveField
in interface IClassHierarchy
IllegalArgumentException
- if f is nullIllegalArgumentException
- if klass is nullpublic IMethod resolveMethod(IClass receiverClass, Selector selector)
resolveMethod
in interface IClassHierarchy
receiverClass
- type of receiverselector
- method signatureIllegalArgumentException
- if receiverClass is nullpublic ClassLoaderFactory getFactory()
getFactory
in interface IClassHierarchy
public IClass getLeastCommonSuperclass(IClass a, IClass b)
getLeastCommonSuperclass
in interface IClassHierarchy
IllegalArgumentException
- if A is nullpublic TypeReference getLeastCommonSuperclass(TypeReference a, TypeReference b)
getLeastCommonSuperclass
in interface IClassHierarchy
public IClass lookupClass(TypeReference a)
lookupClass
in interface IClassHierarchy
IClass
for a if found; null if can't find the class.IllegalArgumentException
- if A is nullpublic boolean isSubclassOf(IClass c, IClass t)
isSubclassOf
in interface IClassHierarchy
IllegalArgumentException
- if c is nullpublic boolean implementsInterface(IClass c, IClass i)
implementsInterface
in interface IClassHierarchy
public Collection<IClass> computeSubClasses(TypeReference type)
computeSubClasses
in interface IClassHierarchy
public Collection<TypeReference> getJavaLangErrorTypes()
getJavaLangErrorTypes
in interface IClassHierarchy
public Collection<TypeReference> getJavaLangRuntimeExceptionTypes()
getJavaLangRuntimeExceptionTypes
in interface IClassHierarchy
public boolean isInterface(TypeReference type)
isInterface
in interface IClassHierarchy
public Set<IClass> getImplementors(TypeReference type)
getImplementors
in interface IClassHierarchy
type
- an interfacepublic int getNumberOfClasses()
getNumberOfClasses
in interface IClassHierarchy
public IClassLoader[] getLoaders()
getLoaders
in interface IClassHierarchy
public IClassLoader getLoader(ClassLoaderReference loaderRef)
getLoader
in interface IClassHierarchy
public AnalysisScope getScope()
getScope
in interface IClassHierarchy
public int getNumberOfImmediateSubclasses(IClass klass)
getNumberOfImmediateSubclasses
in interface IClassHierarchy
public Collection<IClass> getImmediateSubclasses(IClass klass)
getImmediateSubclasses
in interface IClassHierarchy
klass
- public static ClassHierarchy make(AnalysisScope scope) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, MonitorUtil.IProgressMonitor monitor) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory, MonitorUtil.IProgressMonitor monitor) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory, Set<Language> languages) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory, Language language) throws ClassHierarchyException
ClassHierarchyException
public static ClassHierarchy make(AnalysisScope scope, ClassLoaderFactory factory, Language language, MonitorUtil.IProgressMonitor monitor) throws ClassHierarchyException
ClassHierarchyException
public IClass getRootClass()
getRootClass
in interface IClassHierarchy
public boolean isRootClass(IClass c) throws IllegalArgumentException
isRootClass
in interface IClassHierarchy
IllegalArgumentException
public int getNumber(IClass c)
getNumber
in interface IClassHierarchy
public boolean isAssignableFrom(IClass c1, IClass c2)
isAssignableFrom
in interface IClassHierarchy
IllegalArgumentException
- if c1 is nullIllegalArgumentException
- if c2 is nullpublic final Set<TypeReference> getUnresolvedClasses()
IClassHierarchy
getUnresolvedClasses
in interface IClassHierarchy