Class Agent


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

      Fields 
      Modifier and Type Field Description
      private static boolean loadedDynamically  
      static java.lang.String VERSION
      This should be generated as part of the build later.
    • Constructor Summary

      Constructors 
      Constructor Description
      Agent()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void agentmain​(java.lang.String agentArguments, java.lang.instrument.Instrumentation instrumentation)
      This method is run when the agent is loaded dynamically.
      static java.util.logging.Logger getLogger()  
      static void initializeAgent​(java.io.InputStream configuration, java.lang.instrument.Instrumentation instrumentation)
      This method can be used to initialize the BCI agent when using it as a stand alone library.
      private static void initializeAgent​(java.lang.String agentArguments, java.lang.instrument.Instrumentation instrumentation)
      Loads the configuration from the file specified in the agentArguments, and initializes the agent.
      static void premain​(java.lang.String agentArguments, java.lang.instrument.Instrumentation instrumentation)
      This method is run when the agent is started from the command line.
      private static void printVersion()  
      private static void retransformClasses​(java.util.Set<java.lang.String> clazzes, java.lang.instrument.Instrumentation instrumentation)
      Retransforms the required classes when the agent is loaded dynamically.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • VERSION

        public static final java.lang.String VERSION
        This should be generated as part of the build later.
        See Also:
        Constant Field Values
      • loadedDynamically

        private static boolean loadedDynamically
    • Constructor Detail

      • Agent

        public Agent()
    • Method Detail

      • premain

        public static void premain​(java.lang.String agentArguments,
                                   java.lang.instrument.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​(java.lang.String agentArguments,
                                     java.lang.instrument.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​(java.io.InputStream configuration,
                                           java.lang.instrument.Instrumentation instrumentation)
                                    throws javax.xml.stream.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:
        javax.xml.stream.XMLStreamException - if the configuration could not be read.
        XMLValidationException
      • getLogger

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

        private static void initializeAgent​(java.lang.String agentArguments,
                                            java.lang.instrument.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​(java.util.Set<java.lang.String> clazzes,
                                               java.lang.instrument.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()