[jdk16] RFR: 8257596: Clarify trusted final fields for record classes
Chris Hegarty
chegar at openjdk.java.net
Fri Dec 11 19:24:54 UTC 2020
On Fri, 11 Dec 2020 17:58:33 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.
Marked as reviewed by chegar (Reviewer).
-------------
PR: https://git.openjdk.java.net/jdk16/pull/14
More information about the core-libs-dev
mailing list