Annotations on Records and Record Components
Remi Forax
forax at univ-mlv.fr
Tue Jan 28 15:22:20 UTC 2020
Hi !
Does JsonProperty declare RECORD_COMPONENT has target ?
If no, that's why you don't see it on the record component.
But everything is not lost, the annotations can also be propagated to the members of the record,
the generated fields and methods, you can checkout.
cheers,
Rémi
----- Mail original -----
> De: "Summers Pittman ℝ" <secondsun at gmail.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mardi 28 Janvier 2020 16:13:41
> Objet: Annotations on Records and Record Components
> I created a record but I can't access the annotations on the record
> components.
>
> Given the following record
>
> ```java
> record Record(@JsonProperty("id") int id, @JsonProperty("text") String
> text){ }
> ```
>
> I ran the following code to reflect the annotations
>
> ```java
> var recClass = Record.class;
> for (RecordComponent recordComponent :
> recClass.getRecordComponents()) {
> System.out.print("RecordComponent : ");
> System.out.println(recordComponent.toString());
> for (Annotation anno :
> recordComponent.getDeclaredAnnotations()) {
> System.out.print("RecordComponent Annotation : ");
> System.out.println(anno);
> }
> }
> ```
>
> and I don't see the annotations listed in the output:
>
> ```txt
> RecordComponent : int id
> RecordComponent : java.lang.String text
> ```
>
> Am I holding it wrong? I'm using Java 14.ea.33 if the version helps.
>
>
> Summers Pittman
>>>Phone:404 941 4698
> >>Java is my crack.
More information about the amber-dev
mailing list