harpoon.ClassFile
Interface HMethod

All Superinterfaces:
Comparable<HMember>, HMember
All Known Subinterfaces:
HConstructor, HInitializer

public interface HMethod
extends 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.34 2003/03/18 03:52:53 salcianu Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HMember, HClass

Nested Class Summary
 
Nested classes/interfaces inherited from interface harpoon.ClassFile.HMember
HMember.MemberComparator
 
Field Summary
static ArrayFactory<HMethod> arrayFactory
          Array factory: returns new HMethod[].
 
Fields inherited from interface harpoon.ClassFile.HMember
memberComparator
 
Method Summary
 boolean equals(Object obj)
          Compares this HMethod against the specified object.
 HClass getDeclaringClass()
          Returns the HClass object representing the class or interface that declares the method represented by this HMethod object.
 String getDescriptor()
          Returns the descriptor for this method.
 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.
 HType[] getGenericParameterTypes()
          Returns an array of HType objects that represent the formal parameter types, in declaration order, of the method represented by this HMethod object.
 HType getGenericReturnType()
          Returns an HType object that represents the formal return type of the method represented by this HMethod object.
 int getModifiers()
          Returns the Java language modifiers for the method represented by this HMethod object, as an integer.
 HMethodMutator getMutator()
          Returns a mutator for this HMethod, or null if the object is immutable.
 String getName()
          Returns the name of the method represented by this HMethod object, as a String.
 String[] getParameterNames()
          Returns an array of String objects giving the declared names of the formal parameters of the method.
 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.
 HClass getReturnType()
          Returns a HClass object that represents the formal return type of the method represented by this HMethod object.
 HMethodTypeVariable[] getTypeParameters()
          Returns an array of HMethodTypeVariable objects that represent the type variables declared by the method represented by this HMethod object, in declaration order.
 boolean isInterfaceMethod()
          Determines whether this HMethod is an interface method.
 boolean isStatic()
          Determines whether this is a static method.
 boolean isSynthetic()
          Determines whether this HMethod is synthetic, in the sense of "associated with an inner-class; not programmer declared".
 String toString()
          Returns a string describing this HMethod.
 
Methods inherited from interface harpoon.ClassFile.HMember
compareTo, hashCode
 

Field Detail

arrayFactory

static final ArrayFactory<HMethod> arrayFactory
Array factory: returns new HMethod[].

Method Detail

getDeclaringClass

HClass getDeclaringClass()
Returns the HClass object representing the class or interface that declares the method represented by this HMethod object.

Specified by:
getDeclaringClass in interface HMember

getName

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

Specified by:
getName in interface HMember

getModifiers

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.

Specified by:
getModifiers in interface HMember
See Also:
Modifier

getReturnType

HClass getReturnType()
Returns a HClass object that represents the formal return type of the method represented by this HMethod object. Returns HClass.Void if the method returns no value.


getDescriptor

String getDescriptor()
Returns the descriptor for this method. The format of a method string descriptor is defined in Section 4.3 of the JVM specification.

Specified by:
getDescriptor in interface HMember

getParameterTypes

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.


getParameterNames

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.


getExceptionTypes

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.


isSynthetic

boolean isSynthetic()
Determines whether this HMethod is synthetic, in the sense of "associated with an inner-class; not programmer declared".

Specified by:
isSynthetic in interface HMember

isInterfaceMethod

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

Returns:
true if the declaring class is an interface, unless this method represents the static class initializer of the interface.

isStatic

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


getMutator

HMethodMutator getMutator()
Returns a mutator for this HMethod, or null if the object is immutable.


equals

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

toString

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

getGenericParameterTypes

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

In particular, if the compile-time type of any formal parameter is a type variable or a parameterized type, than an object of the appropriate type (i.e., HTypeVariable or HParameterizedType) will be returned.


getGenericReturnType

HType getGenericReturnType()
Returns an HType object that represents the formal return type of the method represented by this HMethod object. In particular, if the compile-time return type a parameterized type, than an object of the appropriate type (i.e., HTypeVariable or HParameterizedType will be returned.


getTypeParameters

HMethodTypeVariable[] getTypeParameters()
Returns an array of HMethodTypeVariable objects that represent the type variables declared by the method represented by this HMethod object, in declaration order. Returns an array of length 0 if the underlying method declares no type variables.