Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic loading of agents will be disallowed in future JDK versions #1

Open
FeldrinH opened this issue Apr 3, 2024 · 2 comments
Open

Comments

@FeldrinH
Copy link
Collaborator

FeldrinH commented Apr 3, 2024

Currently, JDK 21 and newer produce the following deprecation warning when visualizing recursive functions with dendroloj:

WARNING: A Java agent has been loaded dynamically (<path to agent JAR>)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

As per https://openjdk.org/jeps/451, dynamically loading agents will be disallowed by default in future JDK version.
Dendroloj uses a dynamically loaded ByteBuddy agent to instrument methods annotated with @Grow, so this will prevent using dendroloj without setting extra JVM flags in the future.

We need to figure out some path forward once using dynamically loaded agents is disallowed. Currently there seem to be 4 main possibilites:

  1. There is some hope that the limited instrumentation API mentioned under Future Work in the JEP will be enough for us, but that is not guaranteed. It also may or may not require the user to to use the Java 9 module system, which would affect usability and require extra documentation.
  2. It is possible for the user to manually set the -XX:+EnableDynamicAgentLoading flag, though this will affect usability of the library and will require extra documentation.
  3. We develop a plugin for IDE-s that we want to support, which can automatically configure the relevant JVM flags. This is potentially a lot of extra work and creates a divide between supported and unsupported IDE-s. This does have an additional benefit: we can potentially use the plugin to automatically install dendroloj, which could reduce the number of manual installation steps.
  4. We might find a different way to instrument function calls that does not depend on loading an agent. I have not found any good candidates for this, but the possibility cannot be ruled out.

TODO: Create issues and discussions in the relevant places to get feedback from other developers and maintainers on how to deal with this.

@FeldrinH
Copy link
Collaborator Author

FeldrinH commented Apr 3, 2024

Some potentially relevant discussion: mockito/mockito#3037

@FeldrinH
Copy link
Collaborator Author

Update: The latest version of dendroloj will supress the warning, but when this eventually becomes a hard error we will still have to solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant