-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8267555: Fix class file version during redefinition after 8238048 #4149
Conversation
👋 Welcome back simonis! 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.
I'm sorry for the delay and for introducing the bug. I'm hopefully back in the frame of mind I was in when making the change. See if what I said makes sense.
u2 old_major_version = the_class->constants()->major_version(); | ||
the_class->constants()->set_major_version(scratch_class->constants()->major_version()); | ||
scratch_class->constants()->set_major_version(old_major_version); | ||
|
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.
This looks correct. copy_fields doesn't swap the versions, and I think that's what we want to do.
The source_name_index should match the scratch_class which is above, and the generic_signature_index is checked that it matches, and the one in the scratch constant pool should be adjusted to match the merged constant pool. So I think that's ok.
test/hotspot/jtreg/runtime/ConstantPool/ClassVersion/ClassVersionAfterRedefine.java
Outdated
Show resolved
Hide resolved
Hi Coleen, thanks for reviewing my change. I've updated the code as suggested and moved the test to the new location. Thanks for pointing me to Best regards, |
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.
Yes, this looks good. Isn't RedefineClassHelper great? Thanks!
@simonis 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 125 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ 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.
Hi Volker,
The fix looks okay to me.
Thank you for fixing it!
Serguei
/integrate |
@simonis Since your change was applied there have been 130 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 1d2c7ac. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In jdk15, JDK-8238048 moved the class file versions from the
InstanceKlass
into theConstantPool
and introduced a new methodConstantPool::copy_fields(const ConstantPool* orig)
which copies not only thesource_file_name_index
,generic_signature_index
andhas_dynamic_constant
fromorig
to the currentConstantPool
object, but also the minor and major class file version.This new
copy_fields()
method is now called during class redefinition (inVM_RedefineClasses::merge_cp_and_rewrite()
) at places where previously only thehas_dynamic_constant
attribute was copied from the old to the new version of the class. If the new version of the class has a different class file version than the previous one, this different class file version will now be overwritten with the class file version of the previous, original class.In
VM_RedefineClasses::load_new_class_versions()
, afterVM_RedefineClasses::merge_cp_and_rewrite()
has completed, we do another verification step to check the results of constant pool merging (in jdk15 this was controlled byVerifyMergedCPBytecodes
which was on by default, in jdk16 and later this extra verification step only happens in debug builds). If the new class instance uses features which are not available for the class version of the previous class, this verification step will fail.The solution is simple. Don't overwrite the class file version of the new class any more. This also requires reintroducing the update of the class file version for the newly redefined class in
VM_RedefineClasses::redefine_single_class()
like this was done before JDK-8238048.I'm just not sure about the additional new field updates for
source_file_name_index
andgeneric_signature_index
inConstantPool::copy_fields()
which were not done before JDK-8238048. Do we want to preserve these attributes from the original class and write them into the new redefined version? If yes, the new code would be correct and we could remove the following code fromVM_RedefineClasses::redefine_single_class()
because that was already done inConstantPool::copy_fields()
:Otherwise the new would be wrong in the same sense like it was wrong for the class file versions. The differences of between the class file versions and
source_file_name_index
/generic_signature_index
is that the former attributes are mandatory and therefor always available in the new class version while the latter ones are optional. So maybe we should only copy them from the original to the new class if they are not present there already? It currently seems like there's no optimal solution for these attributes?Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4149/head:pull/4149
$ git checkout pull/4149
Update a local copy of the PR:
$ git checkout pull/4149
$ git pull https://git.openjdk.java.net/jdk pull/4149/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4149
View PR using the GUI difftool:
$ git pr show -t 4149
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4149.diff