record components as a first class reflection element

Vicente Romero vicente.romero at oracle.com
Tue Sep 24 20:42:04 UTC 2019



On 9/24/19 3:33 PM, Alex Buckley wrote:
> At first glance, this is sensible because of the first-class status in 
> the JLS of record components and their mapping to accessors.
>
> Based on a check of other implementations of AnnotatedElement, 
> consider `boolean isVarArgs()` (IIRC a varargs component will be 
> allowed) and `String toGenericString()`.

sure, adding those methods make sense,

>
> Alex

Thanks,
Vicente

>
> On 9/24/2019 12:05 PM, Vicente Romero wrote:
>> Hi amber experts,
>>
>> We are considering our next move in the reflection area for records. 
>> It will be hoisting record components to a first class status in the 
>> reflection engine. Our current proposal is to define a new class 
>> named: java.lang.reflect.RecordComponent which will will be roughly 
>> defined as:
>>
>> public final class RecordComponent implements AnnotatedElement {
>>      private String name;
>>      private Class<?> type;
>>      private Method accessor;
>>
>>      public String getName() { return name; }
>>
>>      public Class<?> getType() { return type; }
>>
>>      public Type getGenericType() {...}
>>
>>      public AnnotatedType getAnnotatedType() {....}
>>
>>      public Method getAccessor() { return accessor; }
>> }
>>
>> Along with this change we are also proposing changes to 
>> java.lang.Class. Our proposal there is to remove current method: 
>> java.lang.Class::getRecordAccessors and add a new method named: 
>> java.lang.Class::getRecordComponents which will return a array of 
>> java.lang.reflect.RecordComponents. Thanks in advance for sharing any 
>> feedback on this proposal,
>>
>> Vicente



More information about the amber-spec-experts mailing list