java.lang.reflect.Method
java.lang.Object
None
java.lang.reflect.Member
New as of JDK 1.1
The Method class represents a method of a class. A Method object can be obtained by calling the getMethod() method of a Class object. Method provides methods for getting the name, modifiers, return type, parameters, exceptions, and declaring class of a method. The invoke() method can be used to run the method.
public final class java.lang.reflect.Method extends java.lang.Object implements java.lang.reflect.Member { // Instance Methods public boolean equals(Object obj); public Class getDeclaringClass(); public Class[] getExceptionTypes(); public native int getModifiers(); public String getName(); public Class[] getParameterTypes(); public Class getReturnType(); public int hashCode(); public native Object invoke(Object obj, Object[] args); public String toString(); }
The object to be compared with this object.
true if the objects are equal; false if they are not.
Object.equals()
This method returns true if obj is an instance of Method, and it is equivalent to this Method.
The Class object that represents the class that declared this method.
Member.getDeclaringClass()
This method returns the Class object for the class in which this method is declared.
An array that contains the Class objects that describe the exceptions that can be thrown by this method.
This method returns an array of Class objects that represents the throws clause of this method. If the method does not throw any exceptions, an array of length 0 is returned. As of Java 1.1.2, this method is not properly supported: it always returns an empty array.
An integer that represents the modifier keywords used to declare this method.
Member.getModifiers()
This method returns an integer value that represents the modifiers of this method. The Modifier class should be used to decode the returned value.
The name of this method as a String.
Member.getName()
This method returns the name of this method.
An array that contains the Class objects that describe the parameter types that this method accepts.
This method returns an array of Class objects that represents the parameter types this method accepts. The parameter types are listed in the order in which they are declared. If the method does not take any parameters, an array of length 0 is returned.
The Class object that represents the return type of this method.
This method returns the Class object for the type that this method returns.
A hashcode for this object.
Object.hashCode()
This method returns a hashcode for this Method.
public native Object invoke(Object obj, Object[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
The instance upon which this method is invoked.
An array of arguments to be passed to this method.
A Object that contains the return value of the invoked method.
If the method is inaccessible.
If obj is not the correct type, or if args is the wrong length or contains the wrong types.
If the method itself throws an exception.
If obj is null.
This method executes the method represented by this object on the given object using the given array of arguments. If the method is declared static, the obj parameter is ignored. Otherwise, the object supplied must be an instance of the class that declares this method.
If a particular parameter is of a primitive type, the corresponding argument is automatically unwrapped and converted to the appropriate type, if possible. If that is not possible, an IllegalArgumentException is thrown. If the method itself throws an exception, the exception is placed in an InvocationTargetException, which is then thrown to the caller of invoke().
If the method completes normally, the value it returns is returned. If the value is of a primitive type, the value is wrapped in an appropriate object and the object is returned. If the return type is void, null is returned.
A string representation of this object.
Object.toString()
This method returns a string representation of this Method. This string contains the access modifiers of the method, if any, followed by the return type, the fully qualified name of the declaring class, a period, the name of the method, and a list of the parameters of the method, if any. The list is enclosed by parentheses and the individual parameters are separated by commas. If the method does not have any parameters, just the parentheses are included in the string.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
finalize() |
Object |
getClass() |
Object |
notify() |
Object |
notifyAll() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
Class, Constructor, Field, IllegalAccessException, IllegalArgumentException, InvocationTargetException, Member, Modifier, NullPointerException, Object
This HTML Help has been published using the chm2web software. |