Class.getRecordComponent() javadoc doesn't specify its behavior if the accessor of a record component is not present
Brian Goetz
brian.goetz at oracle.com
Thu Oct 10 20:46:33 UTC 2019
Most reflective methods err on the side of returning null rather than
failing. We could argue about whether that's the right choice, but
that's the precedent that was set early on (just as many methods return
arrays, when we'd rather they return lists.)
On 10/10/2019 4:03 PM, Maurizio Cimadamore wrote:
> It's the usual question: do we fail when we access things reflectively
> that don't seem to be there (either fully or partially) ? Or do we
> silently ignore?
>
> I know that we have examples of both; for instance, nestmates went the
> 'throw an exception' path if a member of the nest cannot be found; but
> annotations went a different path, and annotations that are not found
> are simply discarded.
>
> One might argue that annotations are 'metadata' so less crucial than
> properties such as record component-ness or nestmate-ness. But still
> there's a choice.
>
> And, whatever we do, we should probably be consistent with any kind of
> error that could popup when parsing the record component attribute,
> such as illegal modifiers and such. But, I guess for missing
> annotations on a record component we should be consistent with the
> rest of the JDK, and just drop them on the floor.
>
> Maurizio
>
> On 10/10/2019 20:55, Harold Seigel wrote:
>> The VM should throw a NoSuchMethodError exception in that case?
>>
>> Thanks, Harold
>>
>> On 10/10/2019 3:42 PM, Vicente Romero wrote:
>>> that shouldn't happen, the compiler would generate the accessor if
>>> not present, I guess the VM should verify for that too
>>>
>>> Vicente
>>>
>>> On 10/10/19 2:36 PM, Remi Forax wrote:
>>>> As the title says,
>>>> Class.getRecordComponent() javadoc doesn't specify its behavior if
>>>> the accessor of a record component is not present.
>>>>
>>>> regards,
>>>> Rémi
>>>
More information about the amber-dev
mailing list