RFR: 8267555: Fix class file version during redefinition after 8238048 [v2]
Volker Simonis
simonis at openjdk.java.net
Thu May 27 10:26:52 UTC 2021
On Wed, 26 May 2021 16:42:20 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> Volker Simonis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8267555: Fix class file version during redefinition after 8238048
>
> src/hotspot/share/prims/jvmtiRedefineClasses.cpp line 1861:
>
>> 1859: // Save fields from the old_cp.
>> 1860: merge_cp->copy_fields(old_cp(), true /* skip_version */);
>> 1861: scratch_cp->copy_fields(old_cp(), true /* skip_version */);
>
> Rather than calling copy_fields, maybe this should revert this:
> - if (old_cp->has_dynamic_constant()) {
> - merge_cp->set_has_dynamic_constant();
> - scratch_cp->set_has_dynamic_constant();
> - }
>
> And then the merge_cp->copy_fields(scratch_cp); ?
>
> The merged_cp should look like the scratch_cp (with version number and generic signature, etc) until after verification and then I guess it should look like the old_cp at the end in redefine_single_class().
Yes, that works as well. Updated as suggested.
> test/hotspot/jtreg/runtime/ConstantPool/ClassVersion/ClassVersionAfterRedefine.java line 1:
>
>> 1: /*
>
> Can you put this test in test/hotspot/jtreg/serviceability/jvmti/RedefineClasses directory?
> All the tests do redefinition differently. There is a library RedefineClassHelper that you might be able to use and not have to deal with starting the agent.
>
> @ compile TestClassXXX.jasm // this is the old one
> then in the test read all of TestClassNew.jasm bytecodes, and s/New/XXX/ and use
> RedefineClassHelper.redefine(TestClassXXX.class, newBytes);
>
> See RedefineRunningMethods.java in that directory for an example.
Moved the test to `test/hotspot/jtreg/serviceability/jvmti/RedefineClasses` and use `RedefineClassHelper` as suggested.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4149
More information about the serviceability-dev
mailing list