Thoughts on JFR events for reflection usage?

Robert Toyonaga rtoyonag at redhat.com
Tue Jul 30 18:01:37 UTC 2024


Hi all!

What are your thoughts on an event to record uses of reflection?
The event could contain a field for the action being taken (accessing a
field, invoking a method, etc). It would be an instant event with a
stacktrace. In the case of Quarkus, it's useful to know where and how often
reflection is being used so that we know where to focus efforts if we want
to reduce reflection usage (for performance reasons and also for
compatibility with Native Image). This information is probably helpful in
other use cases as well.

This is a specific case of the more general problem of method tracing:
https://bugs.openjdk.org/browse/JDK-8249859

One potential problem is that if a Java program uses a lot of reflection,
the overhead of such an event might be large, if we emit an event for every
single usage. To avoid that, this event could be throttled similar to how
allocation sampling is done. This would be ok if we want a general picture
of reflection usage. And if a user doesn't want to miss any unique
accesses, they could set the rate to unlimited.

Are there any other foreseeable problems with an event like this?

Thanks!
Robert Toyonaga
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-jfr-dev/attachments/20240730/2ce927c4/attachment.htm>


More information about the hotspot-jfr-dev mailing list