-
Notifications
You must be signed in to change notification settings - Fork 76
8257596: Clarify trusted final fields for record classes #14
Conversation
👋 Welcome back mchung! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Mandy,
The changes look good. Thanks for running the tests and changing the attribute name in the comments.
Could you also change the two comments that you added to jvm.c with these comments:
Comment for JVM_IsRecord():
// A class is a record if and only if it is final and a direct subclass of
// java.lang.Record and has a Record attribute; otherwise, it is not a record.
Comment for JVM_GetRecordComponents():
// Returns an array containing the components of the Record attribute,
// or NULL if the attribute is not present.
//
// Note that this function returns the components of the Record attribute
// even if the class is not a Record.
Thanks, Harold
@mlchung This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 6 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
/integrate |
@mlchung Since your change was applied there have been 7 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 2001da3. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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 ofjava.lang.Record
with the presence of theRecord
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 ofjava.lang.Record
withRecord
attributeJVM_GetRecordComponents
returns anRecordComponents
array ifRecord
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 hasRecord
attribute. SoJVM_GetRecordComponents
returns the content of the classfile.tier1-tier3 and jck-runtime:vm and jck-runtime:lang tests all passed.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk16 pull/14/head:pull/14
$ git checkout pull/14