@@ -1631,7 +1631,7 @@ public Class<?> getEnclosingClass() throws SecurityException {
1631
1631
* in source code, can have a non-empty name including special
1632
1632
* characters, such as "{@code $}".
1633
1633
*
1634
- * <p>The simple name of an {@linkplain isArray() array class} is the simple name of the
1634
+ * <p>The simple name of an {@linkplain # isArray() array class} is the simple name of the
1635
1635
* component type with "[]" appended. In particular the simple
1636
1636
* name of an array class whose component type is anonymous is "[]".
1637
1637
*
@@ -2361,6 +2361,19 @@ public Field[] getDeclaredFields() throws SecurityException {
2361
2361
* Conversely, if {@link #isRecord()} returns {@code true}, then this method
2362
2362
* returns a non-null value.
2363
2363
*
2364
+ * @apiNote
2365
+ * <p> The following method can be used to find the record canonical constructor:
2366
+ *
2367
+ * <pre>{@code
2368
+ * static <T extends Record> Constructor<T> getCanonicalConstructor(Class<T> cls)
2369
+ * throws NoSuchMethodException {
2370
+ * Class<?>[] paramTypes =
2371
+ * Arrays.stream(cls.getRecordComponents())
2372
+ * .map(RecordComponent::getType)
2373
+ * .toArray(Class<?>[]::new);
2374
+ * return cls.getDeclaredConstructor(paramTypes);
2375
+ * }}</pre>
2376
+ *
2364
2377
* @return An array of {@code RecordComponent} objects representing all the
2365
2378
* record components of this record class, or {@code null} if this
2366
2379
* class is not a record class
@@ -3113,15 +3126,15 @@ static <T> boolean casReflectionData(Class<?> clazz,
3113
3126
return unsafe .compareAndSetReference (clazz , reflectionDataOffset , oldData , newData );
3114
3127
}
3115
3128
3116
- static < T > boolean casAnnotationType (Class <?> clazz ,
3117
- AnnotationType oldType ,
3118
- AnnotationType newType ) {
3129
+ static boolean casAnnotationType (Class <?> clazz ,
3130
+ AnnotationType oldType ,
3131
+ AnnotationType newType ) {
3119
3132
return unsafe .compareAndSetReference (clazz , annotationTypeOffset , oldType , newType );
3120
3133
}
3121
3134
3122
- static < T > boolean casAnnotationData (Class <?> clazz ,
3123
- AnnotationData oldData ,
3124
- AnnotationData newData ) {
3135
+ static boolean casAnnotationData (Class <?> clazz ,
3136
+ AnnotationData oldData ,
3137
+ AnnotationData newData ) {
3125
3138
return unsafe .compareAndSetReference (clazz , annotationDataOffset , oldData , newData );
3126
3139
}
3127
3140
}
0 commit comments