Clarifying record reflective support

Chris Hegarty chris.hegarty at oracle.com
Tue Dec 3 17:43:22 UTC 2019


From the point of view of core reflection, I think, “is a record class” is fine. ( which is the wording proposed )

Reflection implicitly relies on the Record attribute to populate the array returned by getRecordComponents ( what else could it do ). I don’t think we need to go further than what is in the proposal that started this thread ( now that it has been pointed out that there is some format checking of the attribute at the JVM level ).

-Chris.

> On 3 Dec 2019, at 17:23, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> 
> On 03/12/2019 17:15, Brian Goetz wrote:
>> I am not even sure if “has a record attribute” isn’t overkill.  “Is a record class” is the more proper semantic specification, and it’s not clear to me that reflection api spec is the place to record these things.
> 
> Should reflection speak about 'has a record attribute XYZ' ? I don't think so (we agree here perhaps).
> 
> But I think that 4.7:
> 
> http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jvms.html#jvms-4.7
> 
> looks pretty much spot on in listing the Record attribute in the same list as Signature, EnclosingMethod and other things that are relevant reflection-wise (hence the format-check).
> 
> Maurizio
> 
>> 
>> Sent from my MacBook Wheel
>> 
>>> On Dec 3, 2019, at 12:12 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
>>> 
>>> On 12/3/2019 8:49 AM, Dan Smith wrote:
>>>> So,
>>>> Fine: "isRecord returns true if the class extends java.lang.Record
>>>> and has a Record attribute." (a little more detailed than most
>>>> reflection methods, but that's probably good)
>>>> Overkill: "isRecord returns true if the class extends
>>>> java.lang.Record and has a Record attribute that conforms to the
>>>> following rules ..."
>>> Yes. "has a Record attribute" is the most that the broadly-read API spec should admit about the class file. Even "has a *well-formed* Record attribute" would be too much, since it quickly devolves into your overkill scenario.
>>> 
>>> Alex



More information about the amber-spec-experts mailing list