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>
allInterfaces
The IClasses that represent all interfaces this class implements (if it's a class) or extends (it it's an interface)protected IClassHierarchy
cha
Governing class hierarchy for this classprotected int
hashCode
hash code; cached here for efficiencyprotected Map<Selector,IMethod>
inheritCache
A mapping from Selector to IMethod used to cache method lookups from superclassesprotected IField[]
instanceFields
The instance fields declared in this class.protected ImmutableByteArray[]
interfaceNames
The names of interfaces for this class.protected T
loader
The object that loaded this class.protected Map<Selector,IMethod>
methodMap
A mapping from Selector to IMethod TODO: get rid of this for classes (though keep it for interfaces) instead ...protected IField[]
staticFields
The static fields declared in this class.protected IClass
superClass
superclassprotected boolean
superclassComputed
Compute the superclass lazily.protected ImmutableByteArray
superName
An Atom which holds the name of the super class.protected TypeReference
typeReference
Canonical type representation
-
Constructor Summary
Constructors Modifier Constructor Description protected
BytecodeClass(T loader, IClassHierarchy cha)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addFieldToList(List<FieldImpl> L, Atom name, ImmutableByteArray fieldType, int accessFlags, Collection<Annotation> annotations, TypeSignature sig)
protected Collection<IClass>
computeAllInterfacesAsCollection()
protected abstract IMethod[]
computeDeclaredMethods()
protected void
computeMethodMapIfNeeded()
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)
IClassHierarchy
getClassHierarchy()
IClassLoader
getClassLoader()
Return the object that represents the defining class loader for this class.abstract Module
getContainer()
Collection<IField>
getDeclaredInstanceFields()
Compute the instance fields declared by this class.Collection<IMethod>
getDeclaredMethods()
Collection<IField>
getDeclaredStaticFields()
Collection<? extends IClass>
getDirectInterfaces()
IField
getField(Atom name)
Finds a field.IField
getField(Atom name, TypeName type)
Finds a field, given a name and a type.IMethod
getMethod(Selector selector)
Finds method matching signature.TypeName
getName()
TypeReference
getReference()
Reader
getSource()
String
getSourceFileName()
IClass
getSuperclass()
int
hashCode()
boolean
isArrayClass()
boolean
isReferenceType()
Does 'this' refer to a reference type? If not, then it refers to a primitive type.protected void
populateFieldArrayFromList(List<FieldImpl> L, IField[] A)
String
toString()
-
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:IClass
Return the object that represents the defining class loader for this class.- Specified by:
getClassLoader
in 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:
getReference
in interfaceIClass
- Returns:
- canonical TypeReference corresponding to this class
-
getSourceFileName
public String getSourceFileName()
- Specified by:
getSourceFileName
in 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:
isArrayClass
in interfaceIClass
- Returns:
- true iff the class is an array class.
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchy
in interfaceIClassHierarchyDweller
-
getName
public TypeName getName()
-
isReferenceType
public boolean isReferenceType()
Description copied from interface:IClass
Does 'this' refer to a reference type? If not, then it refers to a primitive type.- Specified by:
isReferenceType
in interfaceIClass
-
getField
public IField getField(Atom name)
Description copied from interface:IClass
Finds a field.
-
getField
public IField getField(Atom name, TypeName type)
Description copied from interface:IClass
Finds a field, given a name and a type. Returnsnull
if not found.
-
getSuperclass
public IClass getSuperclass()
- Specified by:
getSuperclass
in interfaceIClass
- Returns:
- the superclass, or null if java.lang.Object
-
getAllFields
public Collection<IField> getAllFields()
Description copied from interface:IClass
Compute the instance and static fields declared by this class or any of its superclasses.- Specified by:
getAllFields
in interfaceIClass
-
getAllImplementedInterfaces
public Collection<IClass> getAllImplementedInterfaces()
- Specified by:
getAllImplementedInterfaces
in 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:IClass
Compute the instance fields declared by this class.- Specified by:
getDeclaredInstanceFields
in interfaceIClass
- Returns:
- Collection of IFields
-
getDeclaredStaticFields
public Collection<IField> getDeclaredStaticFields()
- Specified by:
getDeclaredStaticFields
in interfaceIClass
- Returns:
- Collection of IField
-
getDirectInterfaces
public Collection<? extends IClass> getDirectInterfaces()
- Specified by:
getDirectInterfaces
in 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:IClass
Compute the instance fields declared by this class or any of its superclasses.- Specified by:
getAllInstanceFields
in interfaceIClass
-
getAllStaticFields
public Collection<IField> getAllStaticFields()
Description copied from interface:IClass
Compute the static fields declared by this class or any of its superclasses.- Specified by:
getAllStaticFields
in interfaceIClass
-
getAllMethods
public Collection<IMethod> getAllMethods()
Description copied from interface:IClass
Compute the methods declared by this class or any of its superclasses.- Specified by:
getAllMethods
in interfaceIClass
-
getDeclaredMethods
public Collection<IMethod> getDeclaredMethods()
- Specified by:
getDeclaredMethods
in interfaceIClass
- Returns:
- an Iterator of the IMethods declared by this class.
-
getMethod
public IMethod getMethod(Selector selector)
Description copied from interface:IClass
Finds 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 InvalidClassFileException
set up the methodMap mapping- Throws:
InvalidClassFileException
-
getAnnotations
public abstract Collection<Annotation> getAnnotations(boolean runtimeVisible) throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
-