< prev index next >

src/java.base/share/classes/java/lang/reflect/Method.java

Print this page




 339      * the method name, followed by a parenthesized, comma-separated
 340      * list of the method's formal parameter types. If the method
 341      * throws checked exceptions, the parameter list is followed by a
 342      * space, followed by the word throws followed by a
 343      * comma-separated list of the thrown exception types.
 344      * For example:
 345      * <pre>
 346      *    public boolean java.lang.Object.equals(java.lang.Object)
 347      * </pre>
 348      *
 349      * <p>The access modifiers are placed in canonical order as
 350      * specified by "The Java Language Specification".  This is
 351      * {@code public}, {@code protected} or {@code private} first,
 352      * and then other modifiers in the following order:
 353      * {@code abstract}, {@code default}, {@code static}, {@code final},
 354      * {@code synchronized}, {@code native}, {@code strictfp}.
 355      *
 356      * @return a string describing this {@code Method}
 357      *
 358      * @jls 8.4.3 Method Modifiers


 359      */
 360     public String toString() {
 361         return sharedToString(Modifier.methodModifiers(),
 362                               isDefault(),
 363                               parameterTypes,
 364                               exceptionTypes);
 365     }
 366 
 367     @Override
 368     void specificToStringHeader(StringBuilder sb) {
 369         sb.append(getReturnType().getTypeName()).append(' ');
 370         sb.append(getDeclaringClass().getTypeName()).append('.');
 371         sb.append(getName());
 372     }
 373 
 374     /**
 375      * Returns a string describing this {@code Method}, including
 376      * type parameters.  The string is formatted as the method access
 377      * modifiers, if any, followed by an angle-bracketed
 378      * comma-separated list of the method's type parameters, if any,


 392      * type parameters, the type parameter list is elided; if the type
 393      * parameter list is present, a space separates the list from the
 394      * class name.  If the method is declared to throw exceptions, the
 395      * parameter list is followed by a space, followed by the word
 396      * throws followed by a comma-separated list of the generic thrown
 397      * exception types.
 398      *
 399      * <p>The access modifiers are placed in canonical order as
 400      * specified by "The Java Language Specification".  This is
 401      * {@code public}, {@code protected} or {@code private} first,
 402      * and then other modifiers in the following order:
 403      * {@code abstract}, {@code default}, {@code static}, {@code final},
 404      * {@code synchronized}, {@code native}, {@code strictfp}.
 405      *
 406      * @return a string describing this {@code Method},
 407      * include type parameters
 408      *
 409      * @since 1.5
 410      *
 411      * @jls 8.4.3 Method Modifiers


 412      */
 413     @Override
 414     public String toGenericString() {
 415         return sharedToGenericString(Modifier.methodModifiers(), isDefault());
 416     }
 417 
 418     @Override
 419     void specificToGenericStringHeader(StringBuilder sb) {
 420         Type genRetType = getGenericReturnType();
 421         sb.append(genRetType.getTypeName()).append(' ');
 422         sb.append(getDeclaringClass().getTypeName()).append('.');
 423         sb.append(getName());
 424     }
 425 
 426     /**
 427      * Invokes the underlying method represented by this {@code Method}
 428      * object, on the specified object with the specified parameters.
 429      * Individual parameters are automatically unwrapped to match
 430      * primitive formal parameters, and both primitive and reference
 431      * parameters are subject to method invocation conversions as




 339      * the method name, followed by a parenthesized, comma-separated
 340      * list of the method's formal parameter types. If the method
 341      * throws checked exceptions, the parameter list is followed by a
 342      * space, followed by the word throws followed by a
 343      * comma-separated list of the thrown exception types.
 344      * For example:
 345      * <pre>
 346      *    public boolean java.lang.Object.equals(java.lang.Object)
 347      * </pre>
 348      *
 349      * <p>The access modifiers are placed in canonical order as
 350      * specified by "The Java Language Specification".  This is
 351      * {@code public}, {@code protected} or {@code private} first,
 352      * and then other modifiers in the following order:
 353      * {@code abstract}, {@code default}, {@code static}, {@code final},
 354      * {@code synchronized}, {@code native}, {@code strictfp}.
 355      *
 356      * @return a string describing this {@code Method}
 357      *
 358      * @jls 8.4.3 Method Modifiers
 359      * @jls 9.4   Method Declarations
 360      * @jls 9.6.1 Annotation Type Elements
 361      */
 362     public String toString() {
 363         return sharedToString(Modifier.methodModifiers(),
 364                               isDefault(),
 365                               parameterTypes,
 366                               exceptionTypes);
 367     }
 368 
 369     @Override
 370     void specificToStringHeader(StringBuilder sb) {
 371         sb.append(getReturnType().getTypeName()).append(' ');
 372         sb.append(getDeclaringClass().getTypeName()).append('.');
 373         sb.append(getName());
 374     }
 375 
 376     /**
 377      * Returns a string describing this {@code Method}, including
 378      * type parameters.  The string is formatted as the method access
 379      * modifiers, if any, followed by an angle-bracketed
 380      * comma-separated list of the method's type parameters, if any,


 394      * type parameters, the type parameter list is elided; if the type
 395      * parameter list is present, a space separates the list from the
 396      * class name.  If the method is declared to throw exceptions, the
 397      * parameter list is followed by a space, followed by the word
 398      * throws followed by a comma-separated list of the generic thrown
 399      * exception types.
 400      *
 401      * <p>The access modifiers are placed in canonical order as
 402      * specified by "The Java Language Specification".  This is
 403      * {@code public}, {@code protected} or {@code private} first,
 404      * and then other modifiers in the following order:
 405      * {@code abstract}, {@code default}, {@code static}, {@code final},
 406      * {@code synchronized}, {@code native}, {@code strictfp}.
 407      *
 408      * @return a string describing this {@code Method},
 409      * include type parameters
 410      *
 411      * @since 1.5
 412      *
 413      * @jls 8.4.3 Method Modifiers
 414      * @jls 9.4   Method Declarations
 415      * @jls 9.6.1 Annotation Type Elements
 416      */
 417     @Override
 418     public String toGenericString() {
 419         return sharedToGenericString(Modifier.methodModifiers(), isDefault());
 420     }
 421 
 422     @Override
 423     void specificToGenericStringHeader(StringBuilder sb) {
 424         Type genRetType = getGenericReturnType();
 425         sb.append(genRetType.getTypeName()).append(' ');
 426         sb.append(getDeclaringClass().getTypeName()).append('.');
 427         sb.append(getName());
 428     }
 429 
 430     /**
 431      * Invokes the underlying method represented by this {@code Method}
 432      * object, on the specified object with the specified parameters.
 433      * Individual parameters are automatically unwrapped to match
 434      * primitive formal parameters, and both primitive and reference
 435      * parameters are subject to method invocation conversions as


< prev index next >