Package com.ibm.wala.classLoader
Class BytecodeClass<T extends IClassLoader>
- java.lang.Object
-
- com.ibm.wala.classLoader.BytecodeClass<T>
-
- Type Parameters:
T- type of classloader which loads this format of class.
- All Implemented Interfaces:
IClass,IClassHierarchyDweller
public abstract class BytecodeClass<T extends IClassLoader> extends Object implements IClass
A class representing which originates in some form of bytecode.
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<IClass>allInterfacesThe IClasses that represent all interfaces this class implements (if it's a class) or extends (it it's an interface)protected IClassHierarchychaGoverning class hierarchy for this classprotected inthashCodehash code; cached here for efficiencyprotected Map<Selector,IMethod>inheritCacheA mapping from Selector to IMethod used to cache method lookups from superclassesprotected IField[]instanceFieldsThe instance fields declared in this class.protected ImmutableByteArray[]interfaceNamesThe names of interfaces for this class.protected TloaderThe object that loaded this class.protected Map<Selector,IMethod>methodMapA mapping from Selector to IMethod TODO: get rid of this for classes (though keep it for interfaces) instead ...protected IField[]staticFieldsThe static fields declared in this class.protected IClasssuperClasssuperclassprotected booleansuperclassComputedCompute the superclass lazily.protected ImmutableByteArraysuperNameAn Atom which holds the name of the super class.protected TypeReferencetypeReferenceCanonical type representation
-
Constructor Summary
Constructors Modifier Constructor Description protectedBytecodeClass(T loader, IClassHierarchy cha)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddFieldToList(List<FieldImpl> L, Atom name, ImmutableByteArray fieldType, int accessFlags, Collection<Annotation> annotations, TypeSignature sig)protected Collection<IClass>computeAllInterfacesAsCollection()protected abstract IMethod[]computeDeclaredMethods()protected voidcomputeMethodMapIfNeeded()set up the methodMap mappingprotected List<IField>findDeclaredField(Atom name)Collection<IField>getAllFields()Compute the instance and static fields declared by this class or any of its superclasses.Collection<IClass>getAllImplementedInterfaces()Collection<IField>getAllInstanceFields()Compute the instance fields declared by this class or any of its superclasses.Collection<IMethod>getAllMethods()Compute the methods declared by this class or any of its superclasses.Collection<IField>getAllStaticFields()Compute the static fields declared by this class or any of its superclasses.abstract Collection<Annotation>getAnnotations(boolean runtimeVisible)IClassHierarchygetClassHierarchy()IClassLoadergetClassLoader()Return the object that represents the defining class loader for this class.abstract ModulegetContainer()Collection<IField>getDeclaredInstanceFields()Compute the instance fields declared by this class.Collection<IMethod>getDeclaredMethods()Collection<IField>getDeclaredStaticFields()Collection<? extends IClass>getDirectInterfaces()IFieldgetField(Atom name)Finds a field.IFieldgetField(Atom name, TypeName type)Finds a field, given a name and a type.IMethodgetMethod(Selector selector)Finds method matching signature.TypeNamegetName()TypeReferencegetReference()ReadergetSource()StringgetSourceFileName()IClassgetSuperclass()inthashCode()booleanisArrayClass()booleanisReferenceType()Does 'this' refer to a reference type? If not, then it refers to a primitive type.protected voidpopulateFieldArrayFromList(List<FieldImpl> L, IField[] A)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.classLoader.IClass
getAnnotations, getClassInitializer, getModifiers, isAbstract, isInterface, isPrivate, isPublic
-
-
-
-
Field Detail
-
superName
protected ImmutableByteArray superName
An Atom which holds the name of the super class. We cache this for efficiency reasons.
-
interfaceNames
protected ImmutableByteArray[] interfaceNames
The names of interfaces for this class. We cache this for efficiency reasons.
-
loader
protected final T extends IClassLoader loader
The object that loaded this class.
-
cha
protected final IClassHierarchy cha
Governing class hierarchy for this class
-
methodMap
protected volatile Map<Selector,IMethod> methodMap
A mapping from Selector to IMethod TODO: get rid of this for classes (though keep it for interfaces) instead ... use a VMT.
-
inheritCache
protected Map<Selector,IMethod> inheritCache
A mapping from Selector to IMethod used to cache method lookups from superclasses
-
typeReference
protected TypeReference typeReference
Canonical type representation
-
superClass
protected IClass superClass
superclass
-
superclassComputed
protected boolean superclassComputed
Compute the superclass lazily.
-
allInterfaces
protected Collection<IClass> allInterfaces
The IClasses that represent all interfaces this class implements (if it's a class) or extends (it it's an interface)
-
instanceFields
protected IField[] instanceFields
The instance fields declared in this class.
-
staticFields
protected IField[] staticFields
The static fields declared in this class.
-
hashCode
protected int hashCode
hash code; cached here for efficiency
-
-
Constructor Detail
-
BytecodeClass
protected BytecodeClass(T loader, IClassHierarchy cha)
-
-
Method Detail
-
getContainer
public abstract Module getContainer()
-
getClassLoader
public IClassLoader getClassLoader()
Description copied from interface:IClassReturn the object that represents the defining class loader for this class.- Specified by:
getClassLoaderin interfaceIClass- Returns:
- the object that represents the defining class loader for this class.
-
computeDeclaredMethods
protected abstract IMethod[] computeDeclaredMethods() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getReference
public TypeReference getReference()
- Specified by:
getReferencein interfaceIClass- Returns:
- canonical TypeReference corresponding to this class
-
getSourceFileName
public String getSourceFileName()
- Specified by:
getSourceFileNamein interfaceIClass- Returns:
- String holding the name of the source file that defined this class, or null if none found
-
getSource
public Reader getSource()
-
isArrayClass
public boolean isArrayClass()
- Specified by:
isArrayClassin interfaceIClass- Returns:
- true iff the class is an array class.
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchyin interfaceIClassHierarchyDweller
-
getName
public TypeName getName()
-
isReferenceType
public boolean isReferenceType()
Description copied from interface:IClassDoes 'this' refer to a reference type? If not, then it refers to a primitive type.- Specified by:
isReferenceTypein interfaceIClass
-
getField
public IField getField(Atom name)
Description copied from interface:IClassFinds a field.
-
getField
public IField getField(Atom name, TypeName type)
Description copied from interface:IClassFinds a field, given a name and a type. Returnsnullif not found.
-
getSuperclass
public IClass getSuperclass()
- Specified by:
getSuperclassin interfaceIClass- Returns:
- the superclass, or null if java.lang.Object
-
getAllFields
public Collection<IField> getAllFields()
Description copied from interface:IClassCompute the instance and static fields declared by this class or any of its superclasses.- Specified by:
getAllFieldsin interfaceIClass
-
getAllImplementedInterfaces
public Collection<IClass> getAllImplementedInterfaces()
- Specified by:
getAllImplementedInterfacesin interfaceIClass- Returns:
- Collection of (IClass) interfaces this class implements, including all ancestors of interfaces immediately implemented. If this class is an interface, it returns all super-interfaces.
-
getDeclaredInstanceFields
public Collection<IField> getDeclaredInstanceFields()
Description copied from interface:IClassCompute the instance fields declared by this class.- Specified by:
getDeclaredInstanceFieldsin interfaceIClass- Returns:
- Collection of IFields
-
getDeclaredStaticFields
public Collection<IField> getDeclaredStaticFields()
- Specified by:
getDeclaredStaticFieldsin interfaceIClass- Returns:
- Collection of IField
-
getDirectInterfaces
public Collection<? extends IClass> getDirectInterfaces()
- Specified by:
getDirectInterfacesin interfaceIClass- Returns:
- Collection of (IClass) interfaces this class directly implements. If this class is an interface, returns the interfaces it immediately extends.
-
getAllInstanceFields
public Collection<IField> getAllInstanceFields()
Description copied from interface:IClassCompute the instance fields declared by this class or any of its superclasses.- Specified by:
getAllInstanceFieldsin interfaceIClass
-
getAllStaticFields
public Collection<IField> getAllStaticFields()
Description copied from interface:IClassCompute the static fields declared by this class or any of its superclasses.- Specified by:
getAllStaticFieldsin interfaceIClass
-
getAllMethods
public Collection<IMethod> getAllMethods()
Description copied from interface:IClassCompute the methods declared by this class or any of its superclasses.- Specified by:
getAllMethodsin interfaceIClass
-
getDeclaredMethods
public Collection<IMethod> getDeclaredMethods()
- Specified by:
getDeclaredMethodsin interfaceIClass- Returns:
- an Iterator of the IMethods declared by this class.
-
getMethod
public IMethod getMethod(Selector selector)
Description copied from interface:IClassFinds method matching signature. Delegates to superclass if not found.
-
populateFieldArrayFromList
protected void populateFieldArrayFromList(List<FieldImpl> L, IField[] A)
-
computeAllInterfacesAsCollection
protected Collection<IClass> computeAllInterfacesAsCollection()
- Returns:
- Collection of IClasses, representing the interfaces this class implements.
-
addFieldToList
protected void addFieldToList(List<FieldImpl> L, Atom name, ImmutableByteArray fieldType, int accessFlags, Collection<Annotation> annotations, TypeSignature sig)
-
computeMethodMapIfNeeded
protected void computeMethodMapIfNeeded() throws InvalidClassFileExceptionset up the methodMap mapping- Throws:
InvalidClassFileException
-
getAnnotations
public abstract Collection<Annotation> getAnnotations(boolean runtimeVisible) throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
-