On Wed, 13 Mar 2024 19:26:33 GMT, Alex Menkov <amen...@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