RFR: JDK-8315575: Retransform of record class with record component annotation fails with CFE [v3]

Serguei Spitsyn sspitsyn at openjdk.org
Wed Mar 13 21:08:40 UTC 2024


On Wed, 13 Mar 2024 19:26:33 GMT, Alex Menkov <amenkov at openjdk.org> wrote:

>> src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp line 516:
>> 
>>> 514:                         + component->annotations() != nullptr ? 1 : 0
>>> 515:                         + component->type_annotations() != nullptr ? 1 : 0;
>>> 516:     write_u2(attributes_count);
>> 
>> Nit: I would suggest to define this function in the `RecordComponent` class:
>> 
>>   u2 attributes_count() const {
>>      u2 attributes_count =  generic_signature_index() != 0 ? 1 : 0
>>                     + annotations() != nullptr ? 1 : 0
>>                     + type_annotations() != nullptr ? 1 : 0;
>>      return attributes_count;
>>   }
>
> RecordComponent contains information about Record attribute, but it knows nothing about class bytes and attributute_count doesn't make sense for it.
> So I think this is JvmtiClassFileReconstituter responsibility to calculate a value required to generate class bytes for RecordComponent.

The `attributute_count ` is a property of the `RecordComponent` even though it is not stored but calculated.
The `JvmtiClassFileReconstituter` should have a minimal knowledge about this property and how it is calculated, the same as any other consumer of the `RecordComponent`. Thre `RedefineClasses` in the future may need this number as well. Would it be also its responsibility to calculate it?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18161#discussion_r1523914277


More information about the hotspot-runtime-dev mailing list