Class ClassHierarchy

java.lang.Object
EDU.purdue.cs.bloat.editor.ClassHierarchy

public class ClassHierarchy extends Object
ClassHierarchy maintains a graph of the subclass relationships of the classes loaded by the ClassInfoLoader.
See Also:
  • Field Details

    • POS_SHORT

      public static final Type POS_SHORT
    • POS_BYTE

      public static final Type POS_BYTE
    • DEBUG

      public static boolean DEBUG
    • RELAX

      public static boolean RELAX
  • Constructor Details

    • ClassHierarchy

      public ClassHierarchy(EditorContext context, Collection initial, boolean closure)
      Constructor.
      Parameters:
      context - The context in which to access an Editor and other such things.
      initial - The names of the classes that initially constitue the hierarchy.
      closure - Do we get the maximum amount of class information?
  • Method Details

    • addClassNamed

      public void addClassNamed(String name)
      Adds a class of a given name to the ClassHierarchy.
    • subclasses

      public Collection subclasses(Type type)
      Returns the immediate subclasses of a given Type as a Collection of Types.

      The subclass relationship at the classfile level is a little screwy with respect to interfaces. An interface that extends another interface is compiled into an interface that extends java.lang.Object and implements the superinterface. As a result, the interface-subinterface is not captured in subclasses as one may expect. Instead, you have to look at implementors and filter out the classes.

    • superclass

      public Type superclass(Type type)
      Returns the superclass of a given Type. If the Type has no superclass (that is it is Type.OBJECT), then null is returned.
    • interfaces

      public Collection interfaces(Type type)
      Returns the interfaces that a given Type implements as a Collection of Types
    • implementors

      public Collection implementors(Type type)
      Returns the classes (Types) that implement a given interface as a Collection of Types.

      See note in subclasses for information about the interface hierarchy.

    • subclassOf

      public boolean subclassOf(Type a, Type b)
      Returns whether or not a is a subclass of b.
    • classes

      public Collection classes()
      Returns (the Types of) all of the classes and interfaces in the hierarchy.
    • closure

      public boolean closure()
      Returns true if class closure has been computed
    • intersectType

      public Type intersectType(Type a, Type b)
      Returns the intersection of two types. Basically, the interstion of two types is the type (if any) to which both types may be assigned. So, if a is a subtype of b, a is returned. Otherwise, Type.NULL is returned.
    • unionTypes

      public Type unionTypes(Collection types)
      Returns the most refined common supertype for a bunch of Types.
    • unionType

      public Type unionType(Type a, Type b)
      Returns the union of two types. The union of two types is their most refined common supertype. At worst, the union is Type.OBJECT
    • printClasses

      public void printClasses(PrintWriter out, int indent)
      Prints the class hierarchy (i.e. the "extends" hierarchy, interfaces may extends other interfaces) to a PrintWriter.
    • printImplements

      public void printImplements(PrintWriter out, int indent)
      Prints the implements hierarchy to a PrintWriter.
    • methodIsOverridden

      public boolean methodIsOverridden(Type classType, NameAndType nat)
      Determines whether or not a class's method is overriden by any of its subclasses.
    • methodInvoked

      public MemberRef methodInvoked(Type receiver, NameAndType method)
      Returns the MemberRef of the method that would be invoked if a given method of a given type was invoked. Basically, dynamic dispatch is simulated.
    • setToType

      public static Type setToType(BitSet v)
      Given a set of bits representing the range of values some type has, determines what that Type is.
    • typeToSet

      public static BitSet typeToSet(Type type)
      Returns a BitSet representing the possible values of a given integral type.
    • resolvesToWith

      public Set resolvesToWith(MemberRef method)
      Returns a set of ResolvesToWith that represent all subclass methods that override a given method and the subclasses that when used as receivers resolve to that method.
      See Also: