java.lang.reflect.Method Class Reference

Inheritance diagram for java.lang.reflect.Method:

java.lang.reflect.AccessibleObject

List of all members.


Detailed Description

This class must be implemented by the VM vendor.

This class models a method. Information about the method can be accessed, and the method can be invoked dynamically.

Public Member Functions

TypeVariable< Method >[] getTypeParameters ()
String toGenericString ()
Type[] getGenericParameterTypes ()
Type[] getGenericExceptionTypes ()
Type getGenericReturnType ()
Annotation[][] getParameterAnnotations ()
boolean isVarArgs ()
boolean isBridge ()
boolean isSynthetic ()
Object getDefaultValue ()
boolean equals (Object object)
 Compares the specified object to this Method and answer if they are equal.
Class<?> getDeclaringClass ()
 Return the Class associated with the class that defined this method.
Class<?>[] getExceptionTypes ()
 Return an array of the Class objects associated with the exceptions declared to be thrown by this method.
int getModifiers ()
 Return the modifiers for the modeled method.
String getName ()
 Return the name of the modeled method.
Class<?>[] getParameterTypes ()
 Return an array of the Class objects associated with the parameter types of this method.
Class<?> getReturnType ()
 Return the Class associated with the return type of this method.
int hashCode ()
 Answers an integer hash code for the receiver.
Object invoke (Object receiver, Object...args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
 Return the result of dynamically invoking the modeled method.
String toString ()
 Answers a string containing a concise, human-readable description of the receiver.

Private Member Functions

 Method ()
 Prevent this class from being instantiated.


Constructor & Destructor Documentation

java.lang.reflect.Method.Method (  )  [private]

Prevent this class from being instantiated.


Member Function Documentation

String java.lang.reflect.Method.toGenericString (  ) 

Returns the String representation of the method's declaration, including the type parameters.

Returns:
An instance of String.
Since:
1.5

Type [] java.lang.reflect.Method.getGenericParameterTypes (  ) 

Gets the parameter types as an array of Type instances, in declaration order. If the method has no parameters, then an empty array is returned.

Returns:
An array of Type instances.
Exceptions:
GenericSignatureFormatError if the generic method signature is invalid.
TypeNotPresentException if the component type points to a missing type.
MalformedParameterizedTypeException if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

Type [] java.lang.reflect.Method.getGenericExceptionTypes (  ) 

Gets the exception types as an array of Type instances. If the method has no declared exceptions, then an empty array is returned.

Returns:
An array of Type instances.
Exceptions:
GenericSignatureFormatError if the generic method signature is invalid.
TypeNotPresentException if the component type points to a missing type.
MalformedParameterizedTypeException if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

Type java.lang.reflect.Method.getGenericReturnType (  ) 

Gets the return type as a Type instance.

Returns:
A Type instance.
Exceptions:
GenericSignatureFormatError if the generic method signature is invalid.
TypeNotPresentException if the component type points to a missing type.
MalformedParameterizedTypeException if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

Annotation [][] java.lang.reflect.Method.getParameterAnnotations (  ) 

Gets an array of arrays that represent the annotations of the formal parameters of this method. If there are no parameters on this method, then an empty array is returned. If there are no annotations set, then and array of empty arrays is returned.

Returns:
An array of arrays of Annotation instances.
Since:
1.5

boolean java.lang.reflect.Method.isVarArgs (  ) 

Indicates whether or not this method takes a variable number argument.

Returns:
A value of true if a vararg is declare, otherwise false.
Since:
1.5

boolean java.lang.reflect.Method.isBridge (  ) 

Indicates whether or not this method is a bridge.

Returns:
A value of true if this method's a bridge, otherwise false.
Since:
1.5

Object java.lang.reflect.Method.getDefaultValue (  ) 

Gets the default value for the annotation member represented by this method.

Returns:
The default value or null if none.
Exceptions:
TypeNotPresentException if the annotation is of type Class and no definition can be found.
Since:
1.5

boolean java.lang.reflect.Method.equals ( Object  object  ) 

Compares the specified object to this Method and answer if they are equal.

The object must be an instance of Method with the same defining class and parameter types.

Parameters:
object the object to compare
Returns:
true if the specified object is equal to this Method, false otherwise
See also:
hashCode

Class<?> java.lang.reflect.Method.getDeclaringClass (  ) 

Return the Class associated with the class that defined this method.

Returns:
the declaring class

Class<?> [] java.lang.reflect.Method.getExceptionTypes (  ) 

Return an array of the Class objects associated with the exceptions declared to be thrown by this method.

If the method was not declared to throw any exceptions, the array returned will be empty.

Returns:
the declared exception classes

int java.lang.reflect.Method.getModifiers (  ) 

Return the modifiers for the modeled method.

The Modifier class should be used to decode the result.

Returns:
the modifiers
See also:
java.lang.reflect.Modifier

Reimplemented from java.lang.reflect.AccessibleObject.

String java.lang.reflect.Method.getName (  ) 

Return the name of the modeled method.

Returns:
the name

Class<?> [] java.lang.reflect.Method.getParameterTypes (  ) 

Return an array of the Class objects associated with the parameter types of this method.

If the method was declared with no parameters, the array returned will be empty.

Returns:
the parameter types

Class<?> java.lang.reflect.Method.getReturnType (  ) 

Return the Class associated with the return type of this method.

Returns:
the return type

int java.lang.reflect.Method.hashCode (  ) 

Answers an integer hash code for the receiver.

Objects which are equal answer the same value for this method. The hash code for a Method is the hash code of the method's name.

Returns:
the receiver's hash
See also:
equals

Object java.lang.reflect.Method.invoke ( Object  receiver,
Object...  args 
) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException

Return the result of dynamically invoking the modeled method.

This reproduces the effect of receiver.methodName(arg1, arg2, ... , argN) This method performs the following:

Parameters:
receiver The object on which to call the modeled method
args the arguments to the method
Returns:
the new, initialized, object
Exceptions:
java.lang.NullPointerException if the receiver is null for a non-static method
java.lang.IllegalAccessException if the modeled method is not accessible
java.lang.IllegalArgumentException if an incorrect number of arguments are passed, the receiver is incompatible with the declaring class, or an argument could not be converted by a widening conversion
java.lang.reflect.InvocationTargetException if an exception was thrown by the invoked method
See also:
java.lang.reflect.AccessibleObject

String java.lang.reflect.Method.toString (  ) 

Answers a string containing a concise, human-readable description of the receiver.

The format of the string is modifiers (if any) return type declaring class name '.' method name '(' parameter types, separated by ',' ')' If the method throws exceptions, ' throws ' exception types, separated by ',' For example: public native Object java.lang.Method.invoke(Object,Object) throws IllegalAccessException,IllegalArgumentException,InvocationTargetException

Returns:
a printable representation for the receiver


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.