implementation for java.lang.reflect.RecordComponent

Vicente Romero vicente.romero at oracle.com
Tue Oct 8 12:50:52 UTC 2019



On 10/8/19 5:55 AM, Chris Hegarty wrote:
> Vicente,
>
>> On 7 Oct 2019, at 17:25, Chris Hegarty <chris.hegarty at oracle.com> wrote:
>>
>> Vicente,
>>
>>> On 5 Oct 2019, at 00:36, Vicente Romero <vicente.romero at oracle.com> wrote:
>>>
>>> Hi,
>>>
>>> I have pushed which is the first stab in the implementation of java.lang.reflect.RecordComponent, see full code at [1]. I have also removed method Class::getRecordAccessors, in favor or Class::getRecordComponents.
>> Class:: getRecordComponents is not explicit about the ordering of the components. I assume that the returned order is that of the declaration order. Should this be explicit?
>
> Two minor suggestions for Class::getRecordComponents:
>
> 1) Explicitly specify the return order to be the same order that the components are declared in the record header. ( similar wording to that of the JSL draft spec )
>
> 2) Clarify the behavior for non-record classes and records with no components.
>
> +++ b/src/java.base/share/classes/java/lang/Class.java
> @@ -2252,10 +2252,13 @@
>   
>       /**
>        * Returns an array containing {@code RecordComponent} objects reflecting all the
> -     * declared record components of the record represented by this {@code Class} object
> -     *
> -     * @return  the array of {@code RecordComponent} objects representing all the
> -     *          record components of this record
> +     * declared record components of the record represented by this {@code Class} object.
> +     * The components are returned in the same order that they are declared in the
> +     * record header.
> +     *
> +     * @return  The array of {@code RecordComponent} objects representing all the
> +     *          record components of this record. The array is empty if this class
> +     *          is not a record, or if this class is a record with no components.
>        * @throws  SecurityException
>        *          If a security manager, <i>s</i>, is present and any of the
>        *          following conditions is met:
>
> RecordRefletorTest already covers these cases. I can push this change if we agree.
yes I agree with the change, looks good to me,
> -Chris.
Thanks,
Vicente


More information about the amber-dev mailing list