Consider the following:
$ java -javaagent:agent.jar -m foo
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message find class on InstrumentationImpl failed at JPLISAgent.c line: 491
*** java.lang.instrument ASSERTION FAILED ***: "result" at JPLISAgent.c line: 400
FATAL ERROR in native method: processing of -javaagent failed
and also this example:
$ java -Dcom.sun.management.jmxremote.port=5000 -limitmods foo -m foo
Error occurred during initialization of VM
Management agent initialization failure: class sun.management.Agent not found
With the -javaagent example then the issue is that the java.instrument module is not in the module graph. It can be worked around by adding "-addmods java.instrument" to the command line.
In the second example then the issue is that the java.management module is not in the module graph. It can be worked around by ensuring that the module java.management is resolved.
The handling of these options is in arguments.cpp and we need to have these options add to (or create) the system property jdk.launcher.addmods.
In the case of -javaagent then it needs to add java.instrument to the list of modules in the jdk.launcher.addmods value.
In the case of -Dcom.sun.management then it needs to add java.management to the list of modules in the jdk.launcher.addmods value.
$ java -javaagent:agent.jar -m foo
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message find class on InstrumentationImpl failed at JPLISAgent.c line: 491
*** java.lang.instrument ASSERTION FAILED ***: "result" at JPLISAgent.c line: 400
FATAL ERROR in native method: processing of -javaagent failed
and also this example:
$ java -Dcom.sun.management.jmxremote.port=5000 -limitmods foo -m foo
Error occurred during initialization of VM
Management agent initialization failure: class sun.management.Agent not found
With the -javaagent example then the issue is that the java.instrument module is not in the module graph. It can be worked around by adding "-addmods java.instrument" to the command line.
In the second example then the issue is that the java.management module is not in the module graph. It can be worked around by ensuring that the module java.management is resolved.
The handling of these options is in arguments.cpp and we need to have these options add to (or create) the system property jdk.launcher.addmods.
In the case of -javaagent then it needs to add java.instrument to the list of modules in the jdk.launcher.addmods value.
In the case of -Dcom.sun.management then it needs to add java.management to the list of modules in the jdk.launcher.addmods value.