Class ClassHierarchy


  • public class ClassHierarchy
    extends Object
    Queryable inheritance graph of the classes in a ClassPool.
    • Constructor Detail

      • ClassHierarchy

        public ClassHierarchy()
    • Method Detail

      • getNode

        public ClassNode getNode​(String className)
        Looks up an already-registered node.
        Parameters:
        className - internal name of the class
        Returns:
        the node, or null if the hierarchy has no entry for it
      • getAllNodes

        public Collection<ClassNode> getAllNodes()
        Returns:
        an unmodifiable view of every node, pool classes and external references alike
      • getPoolNodes

        public Collection<ClassNode> getPoolNodes()
        Returns:
        a fresh list of the nodes backed by a pool class, excluding external references
      • isAncestorOf

        public boolean isAncestorOf​(String ancestorName,
                                    String descendantName)
        Checks if a class is an ancestor of another class.
        Parameters:
        ancestorName - The potential ancestor class name
        descendantName - The potential descendant class name
        Returns:
        true if ancestor is a superclass or interface of descendant
      • findMethodHierarchy

        public Set<ClassNode> findMethodHierarchy​(String className,
                                                  String methodName,
                                                  String descriptor)
        Finds all classes that declare or inherit a method with the given signature.
        Parameters:
        className - The starting class name
        methodName - The method name
        descriptor - The method descriptor
        Returns:
        Set of ClassNodes that have this method (declared or inherited)
      • getMethod

        public MethodEntry getMethod​(String className,
                                     String methodName,
                                     String descriptor)
        Finds a method declared directly on one class, without walking the hierarchy.
        Parameters:
        className - internal name of the declaring class
        methodName - method name to match
        descriptor - method descriptor to match
        Returns:
        the matching entry, or null if the class is unknown, external, or lacks the method
      • size

        public int size()
        Returns:
        the number of registered nodes