Access Java variable at runtime

Answered

Hello,

Is it possible to monitor/be notified of the changes of a variable in a Java program while it is running (e.g./ creation, assignments...)?

To be more specific, my idea was to add a WebDriverListener, which I've defined, to a WebDriver that the user is using in its program to collect some data and show them in a ToolWindow. The first solution that came to my mind was modifying the PSI before compilation. But that doesn't seem like the best approach and also it wouldn't be an "invisble" process to the user that is using the plugin. How can I grab the variable at creation so that I can add my listener to it?

Please feel free to share any suggestions or also to offer different approaches to help me with my problem.

Thank you

0
2 comments

I'm not aware about any builtin mechanism in the JVM that would allow monitoring such accesses at runtime.

0

Thanks for the confirmation that my idea is probably not possible. I couldn't figure a way to do it.

I guess I will provide a library to the user that interacts with my plugin to gather the data.

0

Please sign in to leave a comment.