1 *java.lang.reflect.Method* *Method* A Method provides information about, and acc
3 public final class Method
4 extends |java.lang.reflect.AccessibleObject|
5 implements |java.lang.reflect.GenericDeclaration|
6 |java.lang.reflect.Member|
8 |java.lang.reflect.Method_Description|
9 |java.lang.reflect.Method_Fields|
10 |java.lang.reflect.Method_Constructors|
11 |java.lang.reflect.Method_Methods|
13 ================================================================================
15 *java.lang.reflect.Method_Methods*
16 |java.lang.reflect.Method.equals(Object)|Compares this Method against the speci
17 |java.lang.reflect.Method.getAnnotation(Class)|
18 |java.lang.reflect.Method.getDeclaredAnnotations()|
19 |java.lang.reflect.Method.getDeclaringClass()|Returns the Class object represen
20 |java.lang.reflect.Method.getDefaultValue()|Returns the default value for the a
21 |java.lang.reflect.Method.getExceptionTypes()|Returns an array of Class objects
22 |java.lang.reflect.Method.getGenericExceptionTypes()|Returns an array of Type o
23 |java.lang.reflect.Method.getGenericParameterTypes()|Returns an array of Type o
24 |java.lang.reflect.Method.getGenericReturnType()|Returns a Type object that rep
25 |java.lang.reflect.Method.getModifiers()|Returns the Java language modifiers fo
26 |java.lang.reflect.Method.getName()|Returns the name of the method represented
27 |java.lang.reflect.Method.getParameterAnnotations()|Returns an array of arrays
28 |java.lang.reflect.Method.getParameterTypes()|Returns an array of Class objects
29 |java.lang.reflect.Method.getReturnType()|Returns a Class object that represent
30 |java.lang.reflect.Method.getTypeParameters()|Returns an array of TypeVariable
31 |java.lang.reflect.Method.hashCode()|Returns a hashcode for this Method.
32 |java.lang.reflect.Method.invoke(Object,Object[])|Invokes the underlying method
33 |java.lang.reflect.Method.isBridge()|Returns true if this method is a bridge m
34 |java.lang.reflect.Method.isSynthetic()|Returns true if this method is a synthe
35 |java.lang.reflect.Method.isVarArgs()|Returns true if this method was declared
36 |java.lang.reflect.Method.toGenericString()|Returns a string describing this Me
37 |java.lang.reflect.Method.toString()|Returns a string describing this Method.
39 *java.lang.reflect.Method_Description*
41 A Method provides information about, and access to, a single method on a class
42 or interface. The reflected method may be a class method or an instance method
43 (including an abstract method).
45 A Method permits widening conversions to occur when matching the actual
46 parameters to invoke with the underlying method's formal parameters, but it
47 throws an IllegalArgumentException if a narrowing conversion would occur.
50 *java.lang.reflect.Method.equals(Object)*
52 public boolean equals(java.lang.Object obj)
54 Compares this Method against the specified object. Returns true if the objects
55 are the same. Two Methods are the same if they were declared by the same class
56 and have the same name and formal parameter types and return type.
59 *java.lang.reflect.Method.getAnnotation(Class)*
61 public |java.lang.annotation.Annotation| getAnnotation(java.lang.Class annotationClass)
66 *java.lang.reflect.Method.getDeclaredAnnotations()*
68 public |java.lang.annotation.Annotation| getDeclaredAnnotations()
73 *java.lang.reflect.Method.getDeclaringClass()*
75 public |java.lang.Class| getDeclaringClass()
77 Returns the Class object representing the class or interface that declares the
78 method represented by this Method object.
81 *java.lang.reflect.Method.getDefaultValue()*
83 public |java.lang.Object| getDefaultValue()
85 Returns the default value for the annotation member represented by this Method
86 instance. If the member is of a primitive type, an instance of the
87 corresponding wrapper type is returned. Returns null if no default is
88 associated with the member, or if the method instance does not represent a
89 declared member of an annotation type.
92 Returns: the default value for the annotation member represented by this Method
94 *java.lang.reflect.Method.getExceptionTypes()*
96 public |java.lang.Class| getExceptionTypes()
98 Returns an array of Class objects that represent the types of the exceptions
99 declared to be thrown by the underlying method represented by this Method
100 object. Returns an array of length 0 if the method declares no exceptions in
104 Returns: the exception types declared as being thrown by the method this object
106 *java.lang.reflect.Method.getGenericExceptionTypes()*
108 public |java.lang.reflect.Type| getGenericExceptionTypes()
110 Returns an array of Type objects that represent the exceptions declared to be
111 thrown by this Method object. Returns an array of length 0 if the underlying
112 method declares no exceptions in its throws clause.
114 If an exception type is a parameterized type, the Type object returned for it
115 must accurately reflect the actual type parameters used in the source code.
117 If an exception type is a type variable or a parameterized type, it is created.
118 Otherwise, it is resolved.
121 Returns: an array of Types that represent the exception types thrown by the underlying
123 *java.lang.reflect.Method.getGenericParameterTypes()*
125 public |java.lang.reflect.Type| getGenericParameterTypes()
127 Returns an array of Type objects that represent the formal parameter types, in
128 declaration order, of the method represented by this Method object. Returns an
129 array of length 0 if the underlying method takes no parameters.
131 If a formal parameter type is a parameterized type, the Type object returned
132 for it must accurately reflect the actual type parameters used in the source
135 If a formal parameter type is a type variable or a parameterized type, it is
136 created. Otherwise, it is resolved.
139 Returns: an array of Types that represent the formal parameter types of the underlying
140 method, in declaration order
141 *java.lang.reflect.Method.getGenericReturnType()*
143 public |java.lang.reflect.Type| getGenericReturnType()
145 Returns a Type object that represents the formal return type of the method
146 represented by this Method object.
148 If the return type is a parameterized type, the Type object returned must
149 accurately reflect the actual type parameters used in the source code.
151 If the return type is a type variable or a parameterized type, it is created.
152 Otherwise, it is resolved.
155 Returns: a Type object that represents the formal return type of the underlying method
156 *java.lang.reflect.Method.getModifiers()*
158 public int getModifiers()
160 Returns the Java language modifiers for the method represented by this Method
161 object, as an integer. The Modifier class should be used to decode the
165 *java.lang.reflect.Method.getName()*
167 public |java.lang.String| getName()
169 Returns the name of the method represented by this Method object, as a String.
172 *java.lang.reflect.Method.getParameterAnnotations()*
174 public |java.lang.annotation.Annotation| getParameterAnnotations()
176 Returns an array of arrays that represent the annotations on the formal
177 parameters, in declaration order, of the method represented by this Method
178 object. (Returns an array of length zero if the underlying method is
179 parameterless. If the method has one or more parameters, a nested array of
180 length zero is returned for each parameter with no annotations.) The annotation
181 objects contained in the returned arrays are serializable. The caller of this
182 method is free to modify the returned arrays; it will have no effect on the
183 arrays returned to other callers.
186 Returns: an array of arrays that represent the annotations on the formal parameters, in
187 declaration order, of the method represented by this Method object
188 *java.lang.reflect.Method.getParameterTypes()*
190 public |java.lang.Class| getParameterTypes()
192 Returns an array of Class objects that represent the formal parameter types, in
193 declaration order, of the method represented by this Method object. Returns an
194 array of length 0 if the underlying method takes no parameters.
197 Returns: the parameter types for the method this object represents
198 *java.lang.reflect.Method.getReturnType()*
200 public |java.lang.Class| getReturnType()
202 Returns a Class object that represents the formal return type of the method
203 represented by this Method object.
206 Returns: the return type for the method this object represents
207 *java.lang.reflect.Method.getTypeParameters()*
209 public |java.lang.reflect.TypeVariable| getTypeParameters()
211 Returns an array of TypeVariable objects that represent the type variables
212 declared by the generic declaration represented by this GenericDeclaration
213 object, in declaration order. Returns an array of length 0 if the underlying
214 generic declaration declares no type variables.
217 Returns: an array of TypeVariable objects that represent the type variables declared by
218 this generic declaration
219 *java.lang.reflect.Method.hashCode()*
221 public int hashCode()
223 Returns a hashcode for this Method. The hashcode is computed as the
224 exclusive-or of the hashcodes for the underlying method's declaring class name
225 and the method's name.
228 *java.lang.reflect.Method.invoke(Object,Object[])*
230 public |java.lang.Object| invoke(
231 java.lang.Object obj,
232 java.lang.Object[] args)
233 throws |java.lang.IllegalAccessException|
234 |java.lang.IllegalArgumentException|
235 |java.lang.reflect.InvocationTargetException|
237 Invokes the underlying method represented by this Method object, on the
238 specified object with the specified parameters. Individual parameters are
239 automatically unwrapped to match primitive formal parameters, and both
240 primitive and reference parameters are subject to method invocation conversions
243 If the underlying method is static, then the specified obj argument is ignored.
246 If the number of formal parameters required by the underlying method is 0, the
247 supplied args array may be of length 0 or null.
249 If the underlying method is an instance method, it is invoked using dynamic
250 method lookup as documented in The Java Language Specification, Second Edition,
251 section 15.12.4.4; in particular, overriding based on the runtime type of the
252 target object will occur.
254 If the underlying method is static, the class that declared the method is
255 initialized if it has not already been initialized.
257 If the method completes normally, the value it returns is returned to the
258 caller of invoke; if the value has a primitive type, it is first appropriately
259 wrapped in an object. However, if the value has the type of an array of a
260 primitive type, the elements of the array are not wrapped in objects; in other
261 words, an array of primitive type is returned. If the underlying method return
262 type is void, the invocation returns null.
264 obj - the object the underlying method is invoked from
265 args - the arguments used for the method call
267 Returns: the result of dispatching the method represented by this object on obj with
269 *java.lang.reflect.Method.isBridge()*
271 public boolean isBridge()
273 Returns true if this method is a bridge method; returns false otherwise.
276 Returns: true if and only if this method is a bridge method as defined by the Java
277 Language Specification.
278 *java.lang.reflect.Method.isSynthetic()*
280 public boolean isSynthetic()
282 Returns true if this method is a synthetic method; returns false otherwise.
285 Returns: true if and only if this method is a synthetic method as defined by the Java
286 Language Specification.
287 *java.lang.reflect.Method.isVarArgs()*
289 public boolean isVarArgs()
291 Returns true if this method was declared to take a variable number of
292 arguments; returns false otherwise.
295 Returns: true if an only if this method was declared to take a variable number of
297 *java.lang.reflect.Method.toGenericString()*
299 public |java.lang.String| toGenericString()
301 Returns a string describing this Method, including type parameters. The string
302 is formatted as the method access modifiers, if any, followed by an
303 angle-bracketed comma-separated list of the method's type parameters, if any,
304 followed by the method's generic return type, followed by a space, followed by
305 the class declaring the method, followed by a period, followed by the method
306 name, followed by a parenthesized, comma-separated list of the method's generic
307 formal parameter types. A space is used to separate access modifiers from one
308 another and from the type parameters or return type. If there are no type
309 parameters, the type parameter list is elided; if the type parameter list is
310 present, a space separates the list from the class name. If the method is
311 declared to throw exceptions, the parameter list is followed by a space,
312 followed by the word throws followed by a comma-separated list of the generic
313 thrown exception types. If there are no type parameters, the type parameter
316 The access modifiers are placed in canonical order as specified by "The Java
317 Language Specification". This is public, protected or private first, and then
318 other modifiers in the following order: abstract, static, final, synchronized
322 Returns: a string describing this Method, include type parameters
323 *java.lang.reflect.Method.toString()*
325 public |java.lang.String| toString()
327 Returns a string describing this Method. The string is formatted as the method
328 access modifiers, if any, followed by the method return type, followed by a
329 space, followed by the class declaring the method, followed by a period,
330 followed by the method name, followed by a parenthesized, comma-separated list
331 of the method's formal parameter types. If the method throws checked
332 exceptions, the parameter list is followed by a space, followed by the word
333 throws followed by a comma-separated list of the thrown exception types. For
336 public boolean java.lang.Object.equals(java.lang.Object)
338 The access modifiers are placed in canonical order as specified by "The Java
339 Language Specification". This is public, protected or private first, and then
340 other modifiers in the following order: abstract, static, final, synchronized