On Tue, 11 Jul 2023 19:34:29 GMT, Ashutosh Mehra <d...@openjdk.org> wrote:
>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Annotations.java >> line 74: >> >>> 72: public U1Array getFieldAnnotations(int fieldIndex) { >>> 73: Address addr = fieldsAnnotations.getValue(getAddress()); >>> 74: ArrayOfU1Array annotationsArray = >>> VMObjectFactory.newObject(ArrayOfU1Array.class, addr); >> >> How about caching this result so you don't need to allocate a new object >> every time this API is called. Same thing in `getFieldTypeAnnotations()`. > > I think VMObjectFactory is a better place to implement the caching behavior > so that all such patterns can benefit from it. I think it is better addressed > in another task. I think maybe you misunderstood what I meant by "cache". I'm not talking about a hashmap of weak references or anything like that. Just add a `ArrayOfU1Array annotationsArray` field to the Annotations object and store the result there. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14735#discussion_r1260246699