Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8265356: need code example for getting canonical constructor of a Record #3556

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1631,7 +1631,7 @@ boolean isPartial() {
* in source code, can have a non-empty name including special
* characters, such as "{@code $}".
*
* <p>The simple name of an {@linkplain isArray() array class} is the simple name of the
* <p>The simple name of an {@linkplain #isArray() array class} is the simple name of the
* component type with "[]" appended. In particular the simple
* name of an array class whose component type is anonymous is "[]".
*
@@ -2364,8 +2364,7 @@ public Method getMethod(String name, Class<?>... parameterTypes)
* <p> This method can be used to find the record canonical constructor:
*
* <pre>{@code
* static <T extends Record>
* Constructor<T> getCanonicalConstructor(Class<T> cls)
* static <T extends Record> Constructor<T> getCanonicalConstructor(Class<T> cls)
* throws NoSuchMethodException {
* Class<?>[] paramTypes =
* Arrays.stream(cls.getRecordComponents())
@@ -3126,15 +3125,15 @@ private String resolveName(String name) {
return unsafe.compareAndSetReference(clazz, reflectionDataOffset, oldData, newData);
}

static <T> boolean casAnnotationType(Class<?> clazz,
AnnotationType oldType,
AnnotationType newType) {
static boolean casAnnotationType(Class<?> clazz,
AnnotationType oldType,
AnnotationType newType) {
return unsafe.compareAndSetReference(clazz, annotationTypeOffset, oldType, newType);
}

static <T> boolean casAnnotationData(Class<?> clazz,
AnnotationData oldData,
AnnotationData newData) {
static boolean casAnnotationData(Class<?> clazz,
AnnotationData oldData,
AnnotationData newData) {
return unsafe.compareAndSetReference(clazz, annotationDataOffset, oldData, newData);
}
}
@@ -79,6 +79,10 @@
* <cite>Java Object Serialization Specification,</cite> Section 1.13,
* "Serialization of Records"</a>.
*
* @apiNote
* A record class structure can be obtained at runtime via reflection.
* See {@link Class#isRecord()} and {@link Class#getRecordComponents()} for more details.
*
* @jls 8.10 Record Types
* @since 16
*/
ProTip! Use n and p to navigate between commits in a pull request.