RFR: 8318124: JFR: Rewrite instrumentation to use Class-File API [v2]
Chen Liang
liach at openjdk.org
Mon Oct 16 06:03:58 UTC 2023
On Mon, 16 Oct 2023 05:02:01 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:
>> src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java line 204:
>>
>>> 202: String typeDescriptor = classDesc.descriptorString();
>>> 203: for (ClassElement ce : classModel.elements()) {
>>> 204: if (ce instanceof RuntimeVisibleAnnotationsAttribute rvaa) {
>>
>> You can use `classModel.findAttribute(Attributes.RUNTIME_VISIBLE_ANNOTATIONS)` instead of looping.
>
> I could not get it to work with findAttribute. No annotations were found.
The existing code will silently finish the loop no-op and return `null` if no RVAA is present. So if `findAttribute` returns `Optional.empty()`, you should just return `null` to match the old behavior.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16195#discussion_r1360143716
More information about the core-libs-dev
mailing list