All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class harpoon.ClassFile.HMethod

java.lang.Object
   |
   +----harpoon.ClassFile.HMethod

public abstract class HMethod
extends Object
implements HMember
An HMethod provides information about, and access to, a single method on a class or interface. The reflected method may be a class method or an instance method (including an abstract method).

Version:
$Id: HMethod.java,v 1.30 1998/11/10 00:44:38 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HMember, HClass

Constructor Index

 o HMethod()

Method Index

 o equals(Object)
Compares this HMethod against the specified object.
 o getCode(String)
Returns an object representing the executable code of this method.
 o getDeclaringClass()
Returns the HClass object representing the class or interface that declares the method represented by this HMethod object.
 o getDescriptor()
Returns the descriptor for this method.
 o getExceptionTypes()
Returns an array of HClass objects that represent the types of the checked exceptions thrown by the underlying method represented by this HMethod object.
 o getModifiers()
Returns the Java language modifiers for the method represented by this HMethod object, as an integer.
 o getName()
Returns the name of the method represented by this HMethod object, as a String.
 o getParameterNames()
Returns an array of String objects giving the declared names of the formal parameters of the method.
 o getParameterTypes()
Returns an array of HClass objects that represent the formal parameter types, in declaration order, of the method represented by this HMethod object.
 o getReturnType()
Returns a HClass object that represents the formal return type of the method represented by this HMethod object.
 o hashCode()
Returns a hashcode for thie HMethod.
 o isInterfaceMethod()
Determines whether this HMethod is an interface method.
 o isStatic()
Determines whether this is a static method.
 o isSynthetic()
Determines whether this HMethod is synthetic.
 o putCode(HCode)
Add a new code representation for this method, or replace a previously existing one.

The 'codetype' string used for getCode is the value of the getName method of codeobj.

 o register(HCodeFactory)
Register an HCodeFactory to be used by the getCode method.
 o toString()
Returns a string describing this HMethod.

Constructors

 o HMethod
 public HMethod()

Methods

 o register
 public static void register(HCodeFactory f)
Register an HCodeFactory to be used by the getCode method.

 o getCode
 public HCode getCode(String codetype)
Returns an object representing the executable code of this method. The only codetype defined by default is "bytecode", which returns an harpoon.IR.Bytecode.Code object, but other codetypes can be registered using the register() method. The getCode() method will use any registered HCodeFactorys in order to create the HCode requested.

Parameters:
codetype - a string representing the code representation you would like.
Returns:
the code representation you requested, or null if no factory for the codetype can be found. null is typically also returned for native methods.
See Also:
putCode
 o putCode
 public void putCode(HCode codeobj)
Add a new code representation for this method, or replace a previously existing one.

The 'codetype' string used for getCode is the value of the getName method of codeobj.

Parameters:
codeobj - an object representing the code, or null to delete a previously existing representation.
See Also:
getCode, getName
 o getDeclaringClass
 public HClass getDeclaringClass()
Returns the HClass object representing the class or interface that declares the method represented by this HMethod object.

 o getName
 public String getName()
Returns the name of the method represented by this HMethod object, as a String.

 o getModifiers
 public int getModifiers()
Returns the Java language modifiers for the method represented by this HMethod object, as an integer. The java.lang.reflect.Modifier class should be used to decode the modifiers.

See Also:
Modifier
 o getReturnType
 public HClass getReturnType()
Returns a HClass object that represents the formal return type of the method represented by this HMethod object.

 o getDescriptor
 public String getDescriptor()
Returns the descriptor for this method.

 o getParameterTypes
 public HClass[] getParameterTypes()
Returns an array of HClass objects that represent the formal parameter types, in declaration order, of the method represented by this HMethod object. Returns an array of length 0 is the underlying method takes no parameters.

 o getParameterNames
 public String[] getParameterNames()
Returns an array of String objects giving the declared names of the formal parameters of the method. The length of the returned array is equal to the number of formal parameters. If there is no LocalVariableTable attribute available for this method, then every element of the returned array will be null.

 o getExceptionTypes
 public HClass[] getExceptionTypes()
Returns an array of HClass objects that represent the types of the checked exceptions thrown by the underlying method represented by this HMethod object. Returns an array of length 0 if the method throws no checked exceptions.

 o isSynthetic
 public boolean isSynthetic()
Determines whether this HMethod is synthetic.

 o isInterfaceMethod
 public boolean isInterfaceMethod()
Determines whether this HMethod is an interface method.

 o isStatic
 public boolean isStatic()
Determines whether this is a static method.

 o equals
 public boolean equals(Object obj)
Compares this HMethod against the specified object. Returns true if the objects are the same. Two HMethods are the same if they were declared by the same class and have the same name and formal parameter types.

Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Returns a hashcode for thie HMethod. The hashcode is computed as the exclusive-or of the hashcodes for the underlying method's declaring class, the method's name, and the method's descriptor string.

Overrides:
hashCode in class Object
 o toString
 public String toString()
Returns a string describing this HMethod. The string is formatted as the method access modifiers, if any, followed by the method return type, followed by a space, followed by the class declaring the method, followed by a period, followed by the method name, followed by a parenthesized, comma-separated list of the method's formal parameter types. If the method throws checked exceptions, the parameter list is followed by a space, followed by the word throws followed by a comma-separated list of the throws exception types. For example:

public boolean java.lang.Object.equals(java.lang.Object)

The access modifiers are placed in canonical order as specified by "The Java Language Specification." This is public, protected, or private first, and then other modifiers in the following order: abstract, static, final, synchronized, native.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index