Class Agent

java.lang.Object
org.openjdk.jmc.agent.Agent

public class Agent extends Object
Small ASM based byte code instrumentation agent for declaratively adding JFR events.
  • Field Details

    • VERSION

      public static final String 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

      public static void premain(String agentArguments, Instrumentation instrumentation)
      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 - the Instrumentation instance, provided to us by the kind JVM.
    • agentmain

      public static void agentmain(String agentArguments, Instrumentation instrumentation)
      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 - the Instrumentation instance, 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 is null.
      instrumentation - the Instrumentation instance.
      Throws:
      XMLStreamException - if the configuration could not be read.
      XMLValidationException
    • getLogger

      public static Logger getLogger()
      Returns:
      the Logger to use for agent related status information.
    • initializeAgent

      private static void initializeAgent(String agentArguments, Instrumentation instrumentation)
      Loads the configuration from the file specified in the agentArguments, and initializes the agent.
      Parameters:
      agentArguments - the file to load from.
      instrumentation - the Instrumentation instance.
    • retransformClasses

      private static void retransformClasses(Set<String> clazzes, Instrumentation instrumentation)
      Retransforms the required classes when the agent is loaded dynamically.
      Parameters:
      clazzes - list of names of classes to retransform
      instrumentation - the Instrumentation instance.
    • printVersion

      private static void printVersion()