[jdk16] RFR: 8257596: Clarify trusted final fields for record classes [v2]
Paul Sandoz
psandoz at openjdk.java.net
Fri Dec 11 19:32:00 UTC 2020
On Fri, 11 Dec 2020 19:29:09 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> This is a follow-up on JDK-8255342 that removes non-specified JVM checks on classes with RecordComponents attributes.
>>
>> See the discussion at https://mail.openjdk.java.net/pipermail/amber-spec-experts/2020-December/002670.html
>>
>> That fixes trusting final fields of records to align with the JLS definition of a record class. `InstanceKlass::is_record` is fixed to check a record class must be final and a direct subclass of `java.lang.Record` with the presence of the `Record` attribute. There is no change to JVM class file validation. I also propose clearly define:
>> - `JVM_IsRecord` returns true if the given class is a record i.e. final and direct subclass of `java.lang.Record` with `Record` attribute
>> - `JVM_GetRecordComponents `returns an `RecordComponents` array if `Record` attribute is present; otherwise, returns NULL. This does not check if it's a record class or not. So it may return non-null on a non-record class if it has `Record` attribute. So `JVM_GetRecordComponents` returns the content of the classfile.
>>
>> tier1-tier3 and jck-runtime:vm and jck-runtime:lang tests all passed.
>
> Mandy Chung has updated the pull request incrementally with one additional commit since the last revision:
>
> Update comments in jvm.cpp per Harold's feedback
IIUC, in summary this correctly aligns the runtime definition of a record with the language, which therefore and appropriately constrains the trusting of non-static final fields to only fields of records, and not more broadly to record-like classes.
-------------
Marked as reviewed by psandoz (Reviewer).
PR: https://git.openjdk.java.net/jdk16/pull/14
More information about the core-libs-dev
mailing list