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
Direct Known Subclasses:
DexIClass, JVMClass

public abstract class BytecodeClass<T extends IClassLoader> extends Object implements IClass
A class representing which originates in some form of bytecode.
  • Field Details

    • 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 Details

  • Method Details

    • 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 interface IClass
      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 interface IClass
      Returns:
      canonical TypeReference corresponding to this class
    • getSourceFileName

      public String getSourceFileName()
      Specified by:
      getSourceFileName in interface IClass
      Returns:
      String holding the name of the source file that defined this class, or null if none found
    • getSource

      public Reader getSource()
      Specified by:
      getSource in interface IClass
      Returns:
      String representing the source file holding this class, or null if not found
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isArrayClass

      public boolean isArrayClass()
      Specified by:
      isArrayClass in interface IClass
      Returns:
      true iff the class is an array class.
    • getClassHierarchy

      public IClassHierarchy getClassHierarchy()
      Specified by:
      getClassHierarchy in interface IClassHierarchyDweller
    • getName

      public TypeName getName()
      Specified by:
      getName in interface IClass
      Returns:
      the TypeName for this class
    • 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 interface IClass
    • getField

      public IField getField(Atom name)
      Description copied from interface: IClass
      Finds a field.
      Specified by:
      getField in interface IClass
    • getField

      public IField getField(Atom name, TypeName type)
      Description copied from interface: IClass
      Finds a field, given a name and a type. Returns null if not found.
      Specified by:
      getField in interface IClass
    • getSuperclass

      public IClass getSuperclass()
      Specified by:
      getSuperclass in interface IClass
      Returns:
      the superclass, or null if java.lang.Object
    • getSuperName

      public TypeName getSuperName()
    • 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 interface IClass
    • getAllImplementedInterfaces

      public Collection<IClass> getAllImplementedInterfaces()
      Specified by:
      getAllImplementedInterfaces in interface IClass
      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 interface IClass
      Returns:
      Collection of IFields
    • getDeclaredStaticFields

      public Collection<IField> getDeclaredStaticFields()
      Specified by:
      getDeclaredStaticFields in interface IClass
      Returns:
      Collection of IField
    • getDirectInterfaces

      public Collection<? extends IClass> getDirectInterfaces()
      Specified by:
      getDirectInterfaces in interface IClass
      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 interface IClass
    • 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 interface IClass
    • 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 interface IClass
    • getDeclaredMethods

      public Collection<IMethod> getDeclaredMethods()
      Specified by:
      getDeclaredMethods in interface IClass
      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.
      Specified by:
      getMethod in interface IClass
      Parameters:
      selector - a method signature
      Returns:
      IMethod from this class matching the signature; null if not found in this class or any superclass.
    • computeAllInterfacesAsCollection

      protected Collection<IClass> computeAllInterfacesAsCollection()
      Returns:
      Collection of IClasses, representing the interfaces this class implements.
    • findDeclaredField

      protected List<IField> findDeclaredField(Atom name)
    • addFieldToList

      protected void addFieldToList(List<FieldImpl> L, Atom name, ImmutableByteArray fieldType, int accessFlags, Collection<Annotation> annotations, Collection<TypeAnnotation> typeAnnotations, 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