326 /**
327 * Returns a string describing this {@code Method}. The string is
328 * formatted as the method access modifiers, if any, followed by
329 * the method return type, followed by a space, followed by the
330 * class declaring the method, followed by a period, followed by
331 * the method name, followed by a parenthesized, comma-separated
332 * list of the method's formal parameter types. If the method
333 * throws checked exceptions, the parameter list is followed by a
334 * space, followed by the word throws followed by a
335 * comma-separated list of the thrown exception types.
336 * For example:
337 * <pre>
338 * public boolean java.lang.Object.equals(java.lang.Object)
339 * </pre>
340 *
341 * <p>The access modifiers are placed in canonical order as
342 * specified by "The Java Language Specification". This is
343 * {@code public}, {@code protected} or {@code private} first,
344 * and then other modifiers in the following order:
345 * {@code abstract}, {@code static}, {@code final},
346 * {@code synchronized}, {@code native}, {@code strictfp}.
347 */
348 public String toString() {
349 return sharedToString(Modifier.methodModifiers(),
350 parameterTypes,
351 exceptionTypes);
352 }
353
354 @Override
355 void specificToStringHeader(StringBuilder sb) {
356 sb.append(Field.getTypeName(getReturnType())).append(' ');
357 sb.append(Field.getTypeName(getDeclaringClass())).append('.');
358 sb.append(getName());
359 }
360
361 /**
362 * Returns a string describing this {@code Method}, including
363 * type parameters. The string is formatted as the method access
364 * modifiers, if any, followed by an angle-bracketed
365 * comma-separated list of the method's type parameters, if any,
366 * followed by the method's generic return type, followed by a
367 * space, followed by the class declaring the method, followed by
368 * a period, followed by the method name, followed by a
369 * parenthesized, comma-separated list of the method's generic
372 * If this method was declared to take a variable number of
373 * arguments, instead of denoting the last parameter as
374 * "<tt><i>Type</i>[]</tt>", it is denoted as
375 * "<tt><i>Type</i>...</tt>".
376 *
377 * A space is used to separate access modifiers from one another
378 * and from the type parameters or return type. If there are no
379 * type parameters, the type parameter list is elided; if the type
380 * parameter list is present, a space separates the list from the
381 * class name. If the method is declared to throw exceptions, the
382 * parameter list is followed by a space, followed by the word
383 * throws followed by a comma-separated list of the generic thrown
384 * exception types. If there are no type parameters, the type
385 * parameter list is elided.
386 *
387 * <p>The access modifiers are placed in canonical order as
388 * specified by "The Java Language Specification". This is
389 * {@code public}, {@code protected} or {@code private} first,
390 * and then other modifiers in the following order:
391 * {@code abstract}, {@code static}, {@code final},
392 * {@code synchronized}, {@code native}, {@code strictfp}.
393 *
394 * @return a string describing this {@code Method},
395 * include type parameters
396 *
397 * @since 1.5
398 */
399 @Override
400 public String toGenericString() {
401 return sharedToGenericString(Modifier.methodModifiers());
402 }
403
404 @Override
405 void specificToGenericStringHeader(StringBuilder sb) {
406 Type genRetType = getGenericReturnType();
407 sb.append( ((genRetType instanceof Class<?>)?
408 Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
409 .append(' ');
410
411 sb.append(Field.getTypeName(getDeclaringClass())).append('.');
412 sb.append(getName());
413 }
414
415 /**
416 * Invokes the underlying method represented by this {@code Method}
417 * object, on the specified object with the specified parameters.
418 * Individual parameters are automatically unwrapped to match
419 * primitive formal parameters, and both primitive and reference
420 * parameters are subject to method invocation conversions as
421 * necessary.
|
326 /**
327 * Returns a string describing this {@code Method}. The string is
328 * formatted as the method access modifiers, if any, followed by
329 * the method return type, followed by a space, followed by the
330 * class declaring the method, followed by a period, followed by
331 * the method name, followed by a parenthesized, comma-separated
332 * list of the method's formal parameter types. If the method
333 * throws checked exceptions, the parameter list is followed by a
334 * space, followed by the word throws followed by a
335 * comma-separated list of the thrown exception types.
336 * For example:
337 * <pre>
338 * public boolean java.lang.Object.equals(java.lang.Object)
339 * </pre>
340 *
341 * <p>The access modifiers are placed in canonical order as
342 * specified by "The Java Language Specification". This is
343 * {@code public}, {@code protected} or {@code private} first,
344 * and then other modifiers in the following order:
345 * {@code abstract}, {@code static}, {@code final},
346 * {@code synchronized}, {@code native}, {@code strictfp},
347 * {@code default}.
348 *
349 * @return a string describing this {@code Method}
350 *
351 * @jls 8.4.3 Method Modifiers
352 */
353 public String toString() {
354 return sharedToString(Modifier.methodModifiers(),
355 isDefault(),
356 parameterTypes,
357 exceptionTypes);
358 }
359
360 @Override
361 void specificToStringHeader(StringBuilder sb) {
362 sb.append(Field.getTypeName(getReturnType())).append(' ');
363 sb.append(Field.getTypeName(getDeclaringClass())).append('.');
364 sb.append(getName());
365 }
366
367 /**
368 * Returns a string describing this {@code Method}, including
369 * type parameters. The string is formatted as the method access
370 * modifiers, if any, followed by an angle-bracketed
371 * comma-separated list of the method's type parameters, if any,
372 * followed by the method's generic return type, followed by a
373 * space, followed by the class declaring the method, followed by
374 * a period, followed by the method name, followed by a
375 * parenthesized, comma-separated list of the method's generic
378 * If this method was declared to take a variable number of
379 * arguments, instead of denoting the last parameter as
380 * "<tt><i>Type</i>[]</tt>", it is denoted as
381 * "<tt><i>Type</i>...</tt>".
382 *
383 * A space is used to separate access modifiers from one another
384 * and from the type parameters or return type. If there are no
385 * type parameters, the type parameter list is elided; if the type
386 * parameter list is present, a space separates the list from the
387 * class name. If the method is declared to throw exceptions, the
388 * parameter list is followed by a space, followed by the word
389 * throws followed by a comma-separated list of the generic thrown
390 * exception types. If there are no type parameters, the type
391 * parameter list is elided.
392 *
393 * <p>The access modifiers are placed in canonical order as
394 * specified by "The Java Language Specification". This is
395 * {@code public}, {@code protected} or {@code private} first,
396 * and then other modifiers in the following order:
397 * {@code abstract}, {@code static}, {@code final},
398 * {@code synchronized}, {@code native}, {@code strictfp},
399 * {@code default}.
400 *
401 * @return a string describing this {@code Method},
402 * include type parameters
403 *
404 * @since 1.5
405 *
406 * @jls 8.4.3 Method Modifiers
407 */
408 @Override
409 public String toGenericString() {
410 return sharedToGenericString(Modifier.methodModifiers(), isDefault());
411 }
412
413 @Override
414 void specificToGenericStringHeader(StringBuilder sb) {
415 Type genRetType = getGenericReturnType();
416 sb.append( ((genRetType instanceof Class<?>)?
417 Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
418 .append(' ');
419
420 sb.append(Field.getTypeName(getDeclaringClass())).append('.');
421 sb.append(getName());
422 }
423
424 /**
425 * Invokes the underlying method represented by this {@code Method}
426 * object, on the specified object with the specified parameters.
427 * Individual parameters are automatically unwrapped to match
428 * primitive formal parameters, and both primitive and reference
429 * parameters are subject to method invocation conversions as
430 * necessary.
|