Package org.openjdk.jmc.agent
Class Agent
java.lang.Object
org.openjdk.jmc.agent.Agent
Small ASM based byte code instrumentation agent for declaratively adding JFR events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static booleanstatic final StringThis should be generated as part of the build later. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidagentmain(String agentArguments, Instrumentation instrumentation) This method is run when the agent is loaded dynamically.static Loggerstatic voidinitializeAgent(InputStream configuration, Instrumentation instrumentation) This method can be used to initialize the BCI agent when using it as a stand alone library.private static voidinitializeAgent(String agentArguments, Instrumentation instrumentation) Loads the configuration from the file specified in the agentArguments, and initializes the agent.static voidpremain(String agentArguments, Instrumentation instrumentation) This method is run when the agent is started from the command line.private static voidprivate static voidretransformClasses(Set<String> clazzes, Instrumentation instrumentation) Retransforms the required classes when the agent is loaded dynamically.
-
Field Details
-
VERSION
This should be generated as part of the build later.- See Also:
-
loadedDynamically
private static boolean loadedDynamically
-
-
Constructor Details
-
Agent
public Agent()
-
-
Method Details
-
premain
This method is run when the agent is started from the command line.- Parameters:
agentArguments- the arguments to the agent, in this case the path to the config file.instrumentation- theInstrumentationinstance, provided to us by the kind JVM.
-
agentmain
This method is run when the agent is loaded dynamically.- Parameters:
agentArguments- the arguments to the agent, in this case the path to the config file.instrumentation- theInstrumentationinstance, provided to us by the kind JVM.
-
initializeAgent
public static void initializeAgent(InputStream configuration, Instrumentation instrumentation) throws XMLStreamException, XMLValidationException This method can be used to initialize the BCI agent when using it as a stand alone library.- Parameters:
configuration- the configuration options, as XML. The stream will be fully read, but not closed. An empty configuration will be used if this argument isnull.instrumentation- theInstrumentationinstance.- Throws:
XMLStreamException- if the configuration could not be read.XMLValidationException
-
getLogger
- Returns:
- the Logger to use for agent related status information.
-
initializeAgent
Loads the configuration from the file specified in the agentArguments, and initializes the agent.- Parameters:
agentArguments- the file to load from.instrumentation- theInstrumentationinstance.
-
retransformClasses
Retransforms the required classes when the agent is loaded dynamically.- Parameters:
clazzes- list of names of classes to retransforminstrumentation- theInstrumentationinstance.
-
printVersion
private static void printVersion()
-