107 private Constructor<T> root;
108
109 @Override
110 Constructor<T> getRoot() {
111 return root;
112 }
113
114 /**
115 * Package-private constructor used by ReflectAccess to enable
116 * instantiation of these objects in Java code from the java.lang
117 * package via jdk.internal.access.JavaLangReflectAccess.
118 */
119 Constructor(Class<T> declaringClass,
120 Class<?>[] parameterTypes,
121 Class<?>[] checkedExceptions,
122 int modifiers,
123 int slot,
124 String signature,
125 byte[] annotations,
126 byte[] parameterAnnotations) {
127 this.clazz = declaringClass;
128 this.parameterTypes = parameterTypes;
129 this.exceptionTypes = checkedExceptions;
130 this.modifiers = modifiers;
131 this.slot = slot;
132 this.signature = signature;
133 this.annotations = annotations;
134 this.parameterAnnotations = parameterAnnotations;
135 }
136
137 /**
138 * Package-private routine (exposed to java.lang.Class via
139 * ReflectAccess) which returns a copy of this Constructor. The copy's
140 * "root" field points to this Constructor.
141 */
142 Constructor<T> copy() {
143 // This routine enables sharing of ConstructorAccessor objects
144 // among Constructor objects which refer to the same underlying
145 // method in the VM. (All of this contortion is only necessary
146 // because of the "accessibility" bit in AccessibleObject,
345 * thrown exception types.
346 *
347 * <p>The only possible modifiers for constructors are the access
348 * modifiers {@code public}, {@code protected} or
349 * {@code private}. Only one of these may appear, or none if the
350 * constructor has default (package) access.
351 *
352 * @return a string describing this {@code Constructor}
353 * @jls 8.8.3 Constructor Modifiers
354 * @jls 8.9.2 Enum Body Declarations
355 */
356 public String toString() {
357 return sharedToString(Modifier.constructorModifiers(),
358 false,
359 parameterTypes,
360 exceptionTypes);
361 }
362
363 @Override
364 void specificToStringHeader(StringBuilder sb) {
365 sb.append(getDeclaringClass().getTypeName());
366 }
367
368 @Override
369 String toShortString() {
370 StringBuilder sb = new StringBuilder("constructor ");
371 sb.append(getDeclaringClass().getTypeName());
372 sb.append('(');
373 StringJoiner sj = new StringJoiner(",");
374 for (Class<?> parameterType : getSharedParameterTypes()) {
375 sj.add(parameterType.getTypeName());
376 }
377 sb.append(sj);
378 sb.append(')');
379 return sb.toString();
380 }
381
382 /**
383 * Returns a string describing this {@code Constructor},
384 * including type parameters. The string is formatted as the
385 * constructor access modifiers, if any, followed by an
386 * angle-bracketed comma separated list of the constructor's type
387 * parameters, if any, including informative bounds of the
388 * type parameters, if any, followed by the fully-qualified name of the
389 * declaring class, followed by a parenthesized, comma-separated
390 * list of the constructor's generic formal parameter types.
391 *
|
107 private Constructor<T> root;
108
109 @Override
110 Constructor<T> getRoot() {
111 return root;
112 }
113
114 /**
115 * Package-private constructor used by ReflectAccess to enable
116 * instantiation of these objects in Java code from the java.lang
117 * package via jdk.internal.access.JavaLangReflectAccess.
118 */
119 Constructor(Class<T> declaringClass,
120 Class<?>[] parameterTypes,
121 Class<?>[] checkedExceptions,
122 int modifiers,
123 int slot,
124 String signature,
125 byte[] annotations,
126 byte[] parameterAnnotations) {
127 assert declaringClass.isPrimaryType();
128 this.clazz = declaringClass;
129 this.parameterTypes = parameterTypes;
130 this.exceptionTypes = checkedExceptions;
131 this.modifiers = modifiers;
132 this.slot = slot;
133 this.signature = signature;
134 this.annotations = annotations;
135 this.parameterAnnotations = parameterAnnotations;
136 }
137
138 /**
139 * Package-private routine (exposed to java.lang.Class via
140 * ReflectAccess) which returns a copy of this Constructor. The copy's
141 * "root" field points to this Constructor.
142 */
143 Constructor<T> copy() {
144 // This routine enables sharing of ConstructorAccessor objects
145 // among Constructor objects which refer to the same underlying
146 // method in the VM. (All of this contortion is only necessary
147 // because of the "accessibility" bit in AccessibleObject,
346 * thrown exception types.
347 *
348 * <p>The only possible modifiers for constructors are the access
349 * modifiers {@code public}, {@code protected} or
350 * {@code private}. Only one of these may appear, or none if the
351 * constructor has default (package) access.
352 *
353 * @return a string describing this {@code Constructor}
354 * @jls 8.8.3 Constructor Modifiers
355 * @jls 8.9.2 Enum Body Declarations
356 */
357 public String toString() {
358 return sharedToString(Modifier.constructorModifiers(),
359 false,
360 parameterTypes,
361 exceptionTypes);
362 }
363
364 @Override
365 void specificToStringHeader(StringBuilder sb) {
366 sb.append(getDeclaringClassTypeName());
367 }
368
369 @Override
370 String toShortString() {
371 StringBuilder sb = new StringBuilder("constructor ");
372 sb.append(getDeclaringClassTypeName());
373 sb.append('(');
374 StringJoiner sj = new StringJoiner(",");
375 for (Class<?> parameterType : getSharedParameterTypes()) {
376 sj.add(parameterType.getTypeName());
377 }
378 sb.append(sj);
379 sb.append(')');
380 return sb.toString();
381 }
382
383 /**
384 * Returns a string describing this {@code Constructor},
385 * including type parameters. The string is formatted as the
386 * constructor access modifiers, if any, followed by an
387 * angle-bracketed comma separated list of the constructor's type
388 * parameters, if any, including informative bounds of the
389 * type parameters, if any, followed by the fully-qualified name of the
390 * declaring class, followed by a parenthesized, comma-separated
391 * list of the constructor's generic formal parameter types.
392 *
|