primary fields, reflection and annotations

Kevin Bourrillion kevinb at google.com
Wed Dec 6 15:42:19 UTC 2017


Ideally, if the annotation has ElementType.FIELD, it would get copied to
the field, and also, if it has ElementType.METHOD, it would get copied to
the accessor method. Of course if it's TYPE_USE then it's part of the type
and should go everywhere the type goes. Lastly, if it has PARAMETER I would
certainly expect it to be findable on the constructor itself.  I would
intuitively expect all these things to work without any need for
ElementType.RECORD_FIELD.


On Wed, Dec 6, 2017 at 10:20 AM, Brian Goetz <brian.goetz at oracle.com> wrote:

> By default, the fields should not be private, but package-access, like
> other classes.  (You are permitted to upgrade them to public.)
>
> But let's ignore the details for a minute, and ask: is a (non-type)
> annotation on a "field" of a record just a field annotation, or is it
> something more?
>
>
> On 12/6/2017 10:10 AM, Remi Forax wrote:
>
>> I suppose it's a good idea to support annotations on record fields,
>>    record Person(@JSONProperty String name);
>> at least the current prototype support that, it considers that the target
>> is an ElementType.FIELD and copy the annotations to the generated fields.
>>
>> To access to the annotation sat runtime, you have to crawle the declared
>> fields of the record which are private.
>> And those annotations are not present as parameter annotation of the
>> primary constructor.
>>
>> I think we should consider how we want to reflect on a record Class,
>>    Do we want a java.lang.reflect.RecordField ?
>>    Do we want a new annotation target RECORD_FIELD ?
>>
>> regards,
>> Rémi
>>
>>
>


-- 
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20171206/b155329d/attachment.html>


More information about the amber-spec-experts mailing list