[External] : Re: New candidate JEP: 451: Prepare to Disallow the Dynamic Loading of Agents
Ron Pressler
ron.pressler at oracle.com
Fri May 12 13:55:28 UTC 2023
> On 11 May 2023, at 17:55, Bruno Borges <Bruno.Borges at microsoft.com> wrote:
>
> Ron,
>
> In the cases I've seen, it is the application that is loading the agent programmatically, first thing they do in their static_void_main method.
>
> This has some benefits like allowing the application to depend on an agent as they do with any other library, through a dependency management tool (Maven/Gradle), and having more easily version upgrading mechanisms.
>
> The -javaagent deployment model is not an option to this, nor is the flag to enable the programmatically approach, as it requires the application *developer* to tune JVM flags to do so.
>
> Only possible solution I thought about was to give jlink a flag that would enable the feature. I wonder if this has been considered.
To Alan’s comment I will only add that the ability of the application developer to control the command line is taken as a given (how else would they add libraries, set the heap size or choose the GC?). We have relied on this assumption heavily since the JRE model (the “system runtime”) was discontinued in JDK 11. However, we would love to get actual reports of situations where this is not the case (agents would be the least of the problems in such cases).
BTW, passing --add-options -XX:+EnableDynamicAgentLoading to jlink should also work (although, as Alan says, applications should definitely not attach agents to themselves; that was already blocked by default since JDK 9, and has required a different flag to enable since then).
— Ron
More information about the jdk-dev
mailing list