[jdk16] RFR: 8257596: Clarify trusted final fields for record classes

Mandy Chung mchung at openjdk.java.net
Fri Dec 11 18:05:01 UTC 2020


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.

-------------

Commit messages:
 - Fix the attribute name in comments
 - Merge branch 'master' of https://github.com/openjdk/jdk16 into 8257596
 - 8257596: Clarify trusted final fields for record classes

Changes: https://git.openjdk.java.net/jdk16/pull/14/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk16&pr=14&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8257596
  Stats: 59 lines in 4 files changed: 29 ins; 10 del; 20 mod
  Patch: https://git.openjdk.java.net/jdk16/pull/14.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk16 pull/14/head:pull/14

PR: https://git.openjdk.java.net/jdk16/pull/14


More information about the core-libs-dev mailing list