113 genericInfo = MethodRepository.make(getGenericSignature(),
114 getFactory());
115 }
116 return genericInfo; //return cached repository
117 }
118
119 /**
120 * Package-private constructor
121 */
122 Method(Class<?> declaringClass,
123 String name,
124 Class<?>[] parameterTypes,
125 Class<?> returnType,
126 Class<?>[] checkedExceptions,
127 int modifiers,
128 int slot,
129 String signature,
130 byte[] annotations,
131 byte[] parameterAnnotations,
132 byte[] annotationDefault) {
133 this.clazz = declaringClass;
134 this.name = name;
135 this.parameterTypes = parameterTypes;
136 this.returnType = returnType;
137 this.exceptionTypes = checkedExceptions;
138 this.modifiers = modifiers;
139 this.slot = slot;
140 this.signature = signature;
141 this.annotations = annotations;
142 this.parameterAnnotations = parameterAnnotations;
143 this.annotationDefault = annotationDefault;
144 }
145
146 /**
147 * Package-private routine (exposed to java.lang.Class via
148 * ReflectAccess) which returns a copy of this Method. The copy's
149 * "root" field points to this Method.
150 */
151 Method copy() {
152 // This routine enables sharing of MethodAccessor objects
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 *
408 * @jls 8.4.3 Method Modifiers
409 * @jls 9.4 Method Declarations
410 * @jls 9.6.1 Annotation Interface Elements
411 */
412 public String toString() {
413 return sharedToString(Modifier.methodModifiers(),
414 isDefault(),
415 parameterTypes,
416 exceptionTypes);
417 }
418
419 @Override
420 void specificToStringHeader(StringBuilder sb) {
421 sb.append(getReturnType().getTypeName()).append(' ');
422 sb.append(getDeclaringClass().getTypeName()).append('.');
423 sb.append(getName());
424 }
425
426 @Override
427 String toShortString() {
428 return "method " + getDeclaringClass().getTypeName() +
429 '.' + toShortSignature();
430 }
431
432 String toShortSignature() {
433 StringJoiner sj = new StringJoiner(",", getName() + "(", ")");
434 for (Class<?> parameterType : getSharedParameterTypes()) {
435 sj.add(parameterType.getTypeName());
436 }
437 return sj.toString();
438 }
439
440 /**
441 * Returns a string describing this {@code Method}, including type
442 * parameters. The string is formatted as the method access
443 * modifiers, if any, followed by an angle-bracketed
444 * comma-separated list of the method's type parameters, if any,
445 * including informative bounds of the type parameters, if any,
446 * followed by the method's generic return type, followed by a
447 * space, followed by the class declaring the method, followed by
448 * a period, followed by the method name, followed by a
471 * {@code synchronized}, {@code native}, {@code strictfp}.
472 *
473 * @return a string describing this {@code Method},
474 * include type parameters
475 *
476 * @since 1.5
477 *
478 * @jls 8.4.3 Method Modifiers
479 * @jls 9.4 Method Declarations
480 * @jls 9.6.1 Annotation Interface Elements
481 */
482 @Override
483 public String toGenericString() {
484 return sharedToGenericString(Modifier.methodModifiers(), isDefault());
485 }
486
487 @Override
488 void specificToGenericStringHeader(StringBuilder sb) {
489 Type genRetType = getGenericReturnType();
490 sb.append(genRetType.getTypeName()).append(' ');
491 sb.append(getDeclaringClass().getTypeName()).append('.');
492 sb.append(getName());
493 }
494
495 /**
496 * Invokes the underlying method represented by this {@code Method}
497 * object, on the specified object with the specified parameters.
498 * Individual parameters are automatically unwrapped to match
499 * primitive formal parameters, and both primitive and reference
500 * parameters are subject to method invocation conversions as
501 * necessary.
502 *
503 * <p>If the underlying method is static, then the specified {@code obj}
504 * argument is ignored. It may be null.
505 *
506 * <p>If the number of formal parameters required by the underlying method is
507 * 0, the supplied {@code args} array may be of length 0 or null.
508 *
509 * <p>If the underlying method is an instance method, it is invoked
510 * using dynamic method lookup as documented in The Java Language
511 * Specification, section {@jls 15.12.4.4}; in particular,
|
113 genericInfo = MethodRepository.make(getGenericSignature(),
114 getFactory());
115 }
116 return genericInfo; //return cached repository
117 }
118
119 /**
120 * Package-private constructor
121 */
122 Method(Class<?> declaringClass,
123 String name,
124 Class<?>[] parameterTypes,
125 Class<?> returnType,
126 Class<?>[] checkedExceptions,
127 int modifiers,
128 int slot,
129 String signature,
130 byte[] annotations,
131 byte[] parameterAnnotations,
132 byte[] annotationDefault) {
133 assert declaringClass.isPrimaryType();
134 this.clazz = declaringClass;
135 this.name = name;
136 this.parameterTypes = parameterTypes;
137 this.returnType = returnType;
138 this.exceptionTypes = checkedExceptions;
139 this.modifiers = modifiers;
140 this.slot = slot;
141 this.signature = signature;
142 this.annotations = annotations;
143 this.parameterAnnotations = parameterAnnotations;
144 this.annotationDefault = annotationDefault;
145 }
146
147 /**
148 * Package-private routine (exposed to java.lang.Class via
149 * ReflectAccess) which returns a copy of this Method. The copy's
150 * "root" field points to this Method.
151 */
152 Method copy() {
153 // This routine enables sharing of MethodAccessor objects
403 * and then other modifiers in the following order:
404 * {@code abstract}, {@code default}, {@code static}, {@code final},
405 * {@code synchronized}, {@code native}, {@code strictfp}.
406 *
407 * @return a string describing this {@code Method}
408 *
409 * @jls 8.4.3 Method Modifiers
410 * @jls 9.4 Method Declarations
411 * @jls 9.6.1 Annotation Interface Elements
412 */
413 public String toString() {
414 return sharedToString(Modifier.methodModifiers(),
415 isDefault(),
416 parameterTypes,
417 exceptionTypes);
418 }
419
420 @Override
421 void specificToStringHeader(StringBuilder sb) {
422 sb.append(getReturnType().getTypeName()).append(' ');
423 sb.append(getDeclaringClassTypeName()).append('.');
424 sb.append(getName());
425 }
426
427 @Override
428 String toShortString() {
429 return "method " + getDeclaringClassTypeName() +
430 '.' + toShortSignature();
431 }
432
433 String toShortSignature() {
434 StringJoiner sj = new StringJoiner(",", getName() + "(", ")");
435 for (Class<?> parameterType : getSharedParameterTypes()) {
436 sj.add(parameterType.getTypeName());
437 }
438 return sj.toString();
439 }
440
441 /**
442 * Returns a string describing this {@code Method}, including type
443 * parameters. The string is formatted as the method access
444 * modifiers, if any, followed by an angle-bracketed
445 * comma-separated list of the method's type parameters, if any,
446 * including informative bounds of the type parameters, if any,
447 * followed by the method's generic return type, followed by a
448 * space, followed by the class declaring the method, followed by
449 * a period, followed by the method name, followed by a
472 * {@code synchronized}, {@code native}, {@code strictfp}.
473 *
474 * @return a string describing this {@code Method},
475 * include type parameters
476 *
477 * @since 1.5
478 *
479 * @jls 8.4.3 Method Modifiers
480 * @jls 9.4 Method Declarations
481 * @jls 9.6.1 Annotation Interface Elements
482 */
483 @Override
484 public String toGenericString() {
485 return sharedToGenericString(Modifier.methodModifiers(), isDefault());
486 }
487
488 @Override
489 void specificToGenericStringHeader(StringBuilder sb) {
490 Type genRetType = getGenericReturnType();
491 sb.append(genRetType.getTypeName()).append(' ');
492 sb.append(getDeclaringClassTypeName()).append('.');
493 sb.append(getName());
494 }
495
496 /**
497 * Invokes the underlying method represented by this {@code Method}
498 * object, on the specified object with the specified parameters.
499 * Individual parameters are automatically unwrapped to match
500 * primitive formal parameters, and both primitive and reference
501 * parameters are subject to method invocation conversions as
502 * necessary.
503 *
504 * <p>If the underlying method is static, then the specified {@code obj}
505 * argument is ignored. It may be null.
506 *
507 * <p>If the number of formal parameters required by the underlying method is
508 * 0, the supplied {@code args} array may be of length 0 or null.
509 *
510 * <p>If the underlying method is an instance method, it is invoked
511 * using dynamic method lookup as documented in The Java Language
512 * Specification, section {@jls 15.12.4.4}; in particular,
|