Interface ClassHierarchy

All Superinterfaces:
Indexer<JClass>, Serializable
All Known Implementing Classes:
ClassHierarchyImpl

public interface ClassHierarchy extends Indexer<JClass>
Manages the classes and class-related resolution of the program being analyzed.
  • Method Details

    • setDefaultClassLoader

      void setDefaultClassLoader(JClassLoader loader)
    • getDefaultClassLoader

      JClassLoader getDefaultClassLoader()
    • setBootstrapClassLoader

      void setBootstrapClassLoader(JClassLoader loader)
    • getBootstrapClassLoader

      JClassLoader getBootstrapClassLoader()
    • getClassLoaders

      Collection<JClassLoader> getClassLoaders()
    • addClass

      void addClass(JClass jclass)
      Adds a JClass into class hierarchy. This API should be invoked everytime JClassLoader loads a new JClass.
    • allClasses

      Stream<JClass> allClasses()
    • applicationClasses

      Stream<JClass> applicationClasses()
    • getClass

      @Nullable JClass getClass(JClassLoader loader, String name)
    • getClass

      @Nullable JClass getClass(String name)
    • getMethod

      @Nullable JMethod getMethod(String methodSig)
      Obtains a method by its signature.
      Parameters:
      methodSig - of the method
      Returns:
      the JMethod for signature if found; otherwise, null.
      Throws:
      AnalysisException - if signature is invalid.
    • getField

      @Nullable JField getField(String fieldSig)
      Obtains a field by its signature.
      Parameters:
      fieldSig - signature of the field
      Returns:
      the JField for signature if found; otherwise, null.
      Throws:
      AnalysisException - if signature is invalid.
    • getJREClass

      @Nullable JClass getJREClass(String name)
      Obtains a JRE class by it name.
      Parameters:
      name - the class name
      Returns:
      the JClass for name if found; otherwise, null.
    • getJREMethod

      @Nullable JMethod getJREMethod(String methodSig)
      Obtains a method declared in a JRE class by its signature.
      Parameters:
      methodSig - of the method
      Returns:
      the JMethod for signature if found; otherwise, null.
      Throws:
      AnalysisException - if signature is invalid.
    • getJREField

      @Nullable JField getJREField(String fieldSig)
      Obtains a field declared in a JRE class by its signature.
      Parameters:
      fieldSig - signature of the field
      Returns:
      the JField for signature if found; otherwise, null.
      Throws:
      AnalysisException - if signature is invalid.
    • resolveMethod

      @Nullable JMethod resolveMethod(MethodRef methodRef)
      Resolves a method reference.
      Returns:
      the concrete method pointed by the method reference, or null if the concrete method cannot be found in the class hierarchy.
    • resolveField

      @Nullable JField resolveField(FieldRef fieldRef)
      Resolves a field reference.
      Returns:
      the concrete field pointed by the field reference, or null if the concrete field cannot be found in the class hierarchy.
    • dispatch

      @Nullable JMethod dispatch(Type receiverType, MethodRef methodRef)
      Dispatches a method reference on a receiver type.
      Returns:
      the target method. If the target cannot be found, returns null.
      Throws:
      AnalysisException - if given receiver type cannot be dispatched (e.g., given a primitive type).
    • dispatch

      @Nullable JMethod dispatch(JClass receiverClass, MethodRef methodRef)
      Dispatches a method reference on a receiver class.
      Returns:
      the target method. If the target cannot be found, returns null.
    • getDirectSubinterfacesOf

      Collection<JClass> getDirectSubinterfacesOf(JClass jclass)
      Returns:
      the direct subinterfaces of given interface.
    • getDirectImplementorsOf

      Collection<JClass> getDirectImplementorsOf(JClass jclass)
      Returns:
      the direct implementors of given interface.
    • getDirectSubclassesOf

      Collection<JClass> getDirectSubclassesOf(JClass jclass)
      Returns:
      the direct subclasses of given class.
    • isSubclass

      boolean isSubclass(JClass superclass, JClass subclass)
    • getAllSubclassesOf

      Collection<JClass> getAllSubclassesOf(JClass jclass)
      Returns all subclasses of the given class (including itself). If the given class is an interface, then return all its direct/indirect subinterfaces and their all direct/indirect implementors; otherwise, return all its direct/indirect subclasses.
      Parameters:
      jclass - the given class.
      Returns:
      all subclasses of given class (including itself).
    • getDirectInnerClassesOf

      Collection<JClass> getDirectInnerClassesOf(JClass jclass)
      Returns:
      the direct inner classes of jclass. If jclass does not have inner classes, an empty collection is returned.