RFR: 8311102: Write annotations in the classfile dumped by SA
Thomas Stuefe
stuefe at openjdk.org
Tue Jul 11 07:45:07 UTC 2023
On Tue, 11 Jul 2023 06:31:24 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Please review this PR that enables ClassWriter to write annotations to the class file being dumped.
>>
>> The fields annotations are stored in `Annotations::_fields_annotations` which is of type `Array<Array<u1>*>`. There is no class in SA that can represent it. I have added ArrayOfU1Array to correspond to the type `Array<Array<u1>*>` and it works. I believe there are better approaches but that would require a bit more refactoring of the classes representing Array types. I will leave that for future work for now.
>>
>> Testing: `test/hotspot/jtreg/serviceability/sa` and `test/jdk/sun/tools/jhsdb`
>> Tested it manually by dumping j.l.String class and comparing the annotations with the original class using javap.
>> The test case mentioned in [JDK-8311101](https://bugs.openjdk.org/browse/JDK-8311101) would provide better coverage.
>
> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstMethod.java line 470:
>
>> 468: if (hasParameterAnnotations()) {
>> 469: offset += 1;
>> 470: }
>
> Code here and in other places could be tightened:
>
>
> int offset = (hasMethodAnnotations() ? 1 : 0) +
> (hasParameterAnnotations() ? 1 : 0) +
> (hasTypeAnnotations() ? 1 : 0);
Possibly even factor it out into separate functions like e.g. `offsetOfGenericSignatureIndex` does.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14735#discussion_r1259254940
More information about the serviceability-dev
mailing list