Hi all,
I hope this is the correct email thread to ask a question related to JEP 451: Prepare to Disallow the Dynamic Loading of Agents<https://openjdk.org/jeps/451>. For some context, we at KTH are trying to build a serviceability tool that would monitor dependencies that are running in the target JVM. We looked at jstack for inspiration as it is able to return the stack trace of the target JVM, but we want classes instead and then we can get dependencies as we have annotated each class with dependency information. While looking at jstack, we noticed that it does not trigger the warning "WARNING: A {Java,JVM TI} agent has been loaded dynamically" when the target JVM is 21. However, when we try to build our own agent using the attach API, we get the warning exactly how it says in the JEP. I initially thought that an exception was made for jstack in the open JDK code but I could find it either here<https://github.com/openjdk/jdk/blob/24c5ff7ba58cb7cf93df07f81484cd8fae60e31e/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java#L107> or here<https://github.com/openjdk/jdk/blob/24c5ff7ba58cb7cf93df07f81484cd8fae60e31e/src/hotspot/share/prims/jvmtiAgent.cpp#L521>. Could anyone please tell us why a warning is not shown when jstack is dynamically attaching itself? Details for reproduction Source code for reproduction is attached. If you use IntelliJ, you can directy load this project and execute the provided run configurations. First executed 'LongRunning' which will simply suspend the thread for a few minutes and then the 'AgentLoader' will try to attach itself dynamically. If you don't use IntelliJ, please add '--add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-modules jdk.jcmd --add-exports jdk.jcmd/sun.tools.jps=ALL-UNNAMED' to your Java compiler and JVM to run the above classes. Regards, Aman Sharma PhD Student KTH Royal Institute of Technology School of Electrical Engineering and Computer Science (EECS) Department of Theoretical Computer Science (TCS) <http://www.kth.se><https://www.kth.se/profile/amansha><https://www.kth.se/profile/amansha> <https://www.kth.se/profile/amansha>https://algomaster99.github.io/
<<attachment: jep451.zip>>