RFR: 8265356: need code example for getting canonical constructor of a Record [v3]

Tagir F.Valeev tvaleev at openjdk.java.net
Sat May 1 07:34:16 UTC 2021


> I decided to show a complete static method in the example, so it could be copied to user utility class as is. Not sure if it's reasonable to add `assert cls.isRecord();` there. Also I don't know whether there's a limitation on max characters in the sample code. Probable a line break in `static <T extends Record>\nConstructor<T> getCanonicalConstructor(Class<T> cls)` is unnecessary.
> 
> ---
> Aside from this PR, I've found a couple of things to clean up in `java.lang.Class`:
> 1. There's erroneous JavaDoc link in `getSimpleName()` JavaDoc (introduced by @jddarcy in #3038). It should be `#isArray()` instead of `isArray()`.
> 2. Methods Atomic::casAnnotationType and Atomic::casAnnotationData have unused type parameters `<T>`.
> 3. Probably too much but AnnotationData can be nicely converted to a record! Not sure, probably nobody wants to have `java.lang.Record` initialized too early or increasing the footprint of such a basic class in the metaspace, so I don't insist on this.
> 
> 
>     private record AnnotationData(
>         Map<Class<? extends Annotation>, Annotation> annotations,
>         Map<Class<? extends Annotation>, Annotation> declaredAnnotations,
>         // Value of classRedefinedCount when we created this AnnotationData instance
>         int redefinedCount) {
>     }
> 
> 
> Please tell me if it's ok to fix 1 and 2 along with this PR.

Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:

  Use @apiNote; this method -> the following method

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3556/files
  - new: https://git.openjdk.java.net/jdk/pull/3556/files/1133ab7d..86cac681

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=3556&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=3556&range=01-02

  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3556.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3556/head:pull/3556

PR: https://git.openjdk.java.net/jdk/pull/3556


More information about the core-libs-dev mailing list