harpoon.Util
Class HClassUtil

java.lang.Object
  extended by harpoon.Util.HClassUtil

public abstract class HClassUtil
extends Object

HClassUtil contains various useful methods for dealing with HClasses that do not seem to belong with the standard HClass methods.

Version:
$Id: HClassUtil.java,v 1.11 2004/02/08 01:56:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
HClassUtil()
           
 
Method Summary
static HClass arrayClass(Linker linker, HClass hc, int dims)
          Make an n-dimensional array class from the given component class.
static HClass baseClass(HClass hc)
          Return the ultimate component type of an array (that is, after all array dimensions have been stripped off).
static HClass commonInterface(HClass a, HClass b)
          Find and return the first common superinterface of a pair of interfaces.
static HClass commonParent(HClass a, HClass b)
          Find a class which is a common parent of both supplied classes.
static HClass commonSuper(HClass a, HClass b)
          Find and return the first common superclass of a pair of classes.
static int dims(HClass hc)
          Count the number of dimensions of an array type.
static HClass[] parents(HClass hc)
          Create an array describing the inheritance of class hc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HClassUtil

public HClassUtil()
Method Detail

dims

public static final int dims(HClass hc)
Count the number of dimensions of an array type.

Returns:
0 for a non-array, n for an n-dimensional array type.

baseClass

public static final HClass baseClass(HClass hc)
Return the ultimate component type of an array (that is, after all array dimensions have been stripped off).

Returns:
input class hc if hc is not an array, otherwise a component class c where c is not an array.

arrayClass

public static final HClass arrayClass(Linker linker,
                                      HClass hc,
                                      int dims)
Make an n-dimensional array class from the given component class. The parameter dims is the number of array dimensions to add.


parents

public static final HClass[] parents(HClass hc)
Create an array describing the inheritance of class hc.

Returns:
an array, where element 0 is the HClass for java.lang.Object, an the last element is hc.

commonSuper

public static final HClass commonSuper(HClass a,
                                       HClass b)
Find and return the first common superclass of a pair of classes. Not valid for interface or array types --- both a and b must be primitive or simple object types.


commonInterface

public static final HClass commonInterface(HClass a,
                                           HClass b)
Find and return the first common superinterface of a pair of interfaces.


commonParent

public static final HClass commonParent(HClass a,
                                        HClass b)
Find a class which is a common parent of both supplied classes. Valid for array, interface, and primitive types.