194
195 /**
196 * Used by Excecutable for annotation sharing.
197 */
198 @Override
199 Executable getRoot() {
200 return root;
201 }
202
203 @Override
204 boolean hasGenericInformation() {
205 return (getGenericSignature() != null);
206 }
207
208 @Override
209 byte[] getAnnotationBytes() {
210 return annotations;
211 }
212
213 /**
214 * {@inheritDoc}
215 */
216 @Override
217 public Class<?> getDeclaringClass() {
218 return clazz;
219 }
220
221 /**
222 * Returns the name of the method represented by this {@code Method}
223 * object, as a {@code String}.
224 */
225 @Override
226 public String getName() {
227 return name;
228 }
229
230 /**
231 * {@inheritDoc}
232 */
233 @Override
234 public int getModifiers() {
355 return false;
356 }
357
358 /**
359 * Returns a hashcode for this {@code Method}. The hashcode is computed
360 * as the exclusive-or of the hashcodes for the underlying
361 * method's declaring class name and the method's name.
362 */
363 public int hashCode() {
364 return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
365 }
366
367 /**
368 * Returns a string describing this {@code Method}. The string is
369 * formatted as the method access modifiers, if any, followed by
370 * the method return type, followed by a space, followed by the
371 * class declaring the method, followed by a period, followed by
372 * the method name, followed by a parenthesized, comma-separated
373 * list of the method's formal parameter types. If the method
374 * throws checked exceptions, the parameter list is followed by a
375 * space, followed by the word throws followed by a
376 * comma-separated list of the thrown exception types.
377 * For example:
378 * <pre>
379 * public boolean java.lang.Object.equals(java.lang.Object)
380 * </pre>
381 *
382 * <p>The access modifiers are placed in canonical order as
383 * specified by "The Java Language Specification". This is
384 * {@code public}, {@code protected} or {@code private} first,
385 * and then other modifiers in the following order:
386 * {@code abstract}, {@code default}, {@code static}, {@code final},
387 * {@code synchronized}, {@code native}, {@code strictfp}.
388 *
389 * @return a string describing this {@code Method}
390 *
391 * @jls 8.4.3 Method Modifiers
392 * @jls 9.4 Method Declarations
393 * @jls 9.6.1 Annotation Type Elements
394 */
395 public String toString() {
411 * type parameters. The string is formatted as the method access
412 * modifiers, if any, followed by an angle-bracketed
413 * comma-separated list of the method's type parameters, if any,
414 * followed by the method's generic return type, followed by a
415 * space, followed by the class declaring the method, followed by
416 * a period, followed by the method name, followed by a
417 * parenthesized, comma-separated list of the method's generic
418 * formal parameter types.
419 *
420 * If this method was declared to take a variable number of
421 * arguments, instead of denoting the last parameter as
422 * "<code><i>Type</i>[]</code>", it is denoted as
423 * "<code><i>Type</i>...</code>".
424 *
425 * A space is used to separate access modifiers from one another
426 * and from the type parameters or return type. If there are no
427 * type parameters, the type parameter list is elided; if the type
428 * parameter list is present, a space separates the list from the
429 * class name. If the method is declared to throw exceptions, the
430 * parameter list is followed by a space, followed by the word
431 * throws followed by a comma-separated list of the generic thrown
432 * exception types.
433 *
434 * <p>The access modifiers are placed in canonical order as
435 * specified by "The Java Language Specification". This is
436 * {@code public}, {@code protected} or {@code private} first,
437 * and then other modifiers in the following order:
438 * {@code abstract}, {@code default}, {@code static}, {@code final},
439 * {@code synchronized}, {@code native}, {@code strictfp}.
440 *
441 * @return a string describing this {@code Method},
442 * include type parameters
443 *
444 * @since 1.5
445 *
446 * @jls 8.4.3 Method Modifiers
447 * @jls 9.4 Method Declarations
448 * @jls 9.6.1 Annotation Type Elements
449 */
450 @Override
451 public String toGenericString() {
452 return sharedToGenericString(Modifier.methodModifiers(), isDefault());
|
194
195 /**
196 * Used by Excecutable for annotation sharing.
197 */
198 @Override
199 Executable getRoot() {
200 return root;
201 }
202
203 @Override
204 boolean hasGenericInformation() {
205 return (getGenericSignature() != null);
206 }
207
208 @Override
209 byte[] getAnnotationBytes() {
210 return annotations;
211 }
212
213 /**
214 * Returns the {@code Class} object representing the class or interface
215 * that declares the method represented by this object.
216 */
217 @Override
218 public Class<?> getDeclaringClass() {
219 return clazz;
220 }
221
222 /**
223 * Returns the name of the method represented by this {@code Method}
224 * object, as a {@code String}.
225 */
226 @Override
227 public String getName() {
228 return name;
229 }
230
231 /**
232 * {@inheritDoc}
233 */
234 @Override
235 public int getModifiers() {
356 return false;
357 }
358
359 /**
360 * Returns a hashcode for this {@code Method}. The hashcode is computed
361 * as the exclusive-or of the hashcodes for the underlying
362 * method's declaring class name and the method's name.
363 */
364 public int hashCode() {
365 return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
366 }
367
368 /**
369 * Returns a string describing this {@code Method}. The string is
370 * formatted as the method access modifiers, if any, followed by
371 * the method return type, followed by a space, followed by the
372 * class declaring the method, followed by a period, followed by
373 * the method name, followed by a parenthesized, comma-separated
374 * list of the method's formal parameter types. If the method
375 * throws checked exceptions, the parameter list is followed by a
376 * space, followed by the word "{@code throws}" followed by a
377 * comma-separated list of the thrown exception types.
378 * For example:
379 * <pre>
380 * public boolean java.lang.Object.equals(java.lang.Object)
381 * </pre>
382 *
383 * <p>The access modifiers are placed in canonical order as
384 * specified by "The Java Language Specification". This is
385 * {@code public}, {@code protected} or {@code private} first,
386 * and then other modifiers in the following order:
387 * {@code abstract}, {@code default}, {@code static}, {@code final},
388 * {@code synchronized}, {@code native}, {@code strictfp}.
389 *
390 * @return a string describing this {@code Method}
391 *
392 * @jls 8.4.3 Method Modifiers
393 * @jls 9.4 Method Declarations
394 * @jls 9.6.1 Annotation Type Elements
395 */
396 public String toString() {
412 * type parameters. The string is formatted as the method access
413 * modifiers, if any, followed by an angle-bracketed
414 * comma-separated list of the method's type parameters, if any,
415 * followed by the method's generic return type, followed by a
416 * space, followed by the class declaring the method, followed by
417 * a period, followed by the method name, followed by a
418 * parenthesized, comma-separated list of the method's generic
419 * formal parameter types.
420 *
421 * If this method was declared to take a variable number of
422 * arguments, instead of denoting the last parameter as
423 * "<code><i>Type</i>[]</code>", it is denoted as
424 * "<code><i>Type</i>...</code>".
425 *
426 * A space is used to separate access modifiers from one another
427 * and from the type parameters or return type. If there are no
428 * type parameters, the type parameter list is elided; if the type
429 * parameter list is present, a space separates the list from the
430 * class name. If the method is declared to throw exceptions, the
431 * parameter list is followed by a space, followed by the word
432 * "{@code throws}" followed by a comma-separated list of the generic
433 * thrown exception types.
434 *
435 * <p>The access modifiers are placed in canonical order as
436 * specified by "The Java Language Specification". This is
437 * {@code public}, {@code protected} or {@code private} first,
438 * and then other modifiers in the following order:
439 * {@code abstract}, {@code default}, {@code static}, {@code final},
440 * {@code synchronized}, {@code native}, {@code strictfp}.
441 *
442 * @return a string describing this {@code Method},
443 * include type parameters
444 *
445 * @since 1.5
446 *
447 * @jls 8.4.3 Method Modifiers
448 * @jls 9.4 Method Declarations
449 * @jls 9.6.1 Annotation Type Elements
450 */
451 @Override
452 public String toGenericString() {
453 return sharedToGenericString(Modifier.methodModifiers(), isDefault());
|