Class AgentLoader


  • final class AgentLoader
    extends java.lang.Object
    This will try to load the agent using the Attach API of JDK6. If you are on an older JDK (v5) you can still use the agent by adding the -javaagent:[pathTojar] to your VM startup script
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • SIZEOF_AGENT_CLASSNAME

        private static final java.lang.String SIZEOF_AGENT_CLASSNAME
        See Also:
        Constant Field Values
      • VIRTUAL_MACHINE_CLASSNAME

        private static final java.lang.String VIRTUAL_MACHINE_CLASSNAME
        See Also:
        Constant Field Values
      • VIRTUAL_MACHINE_ATTACH

        private static final java.lang.reflect.Method VIRTUAL_MACHINE_ATTACH
      • VIRTUAL_MACHINE_DETACH

        private static final java.lang.reflect.Method VIRTUAL_MACHINE_DETACH
      • VIRTUAL_MACHINE_LOAD_AGENT

        private static final java.lang.reflect.Method VIRTUAL_MACHINE_LOAD_AGENT
      • instrumentation

        private static volatile java.lang.instrument.Instrumentation instrumentation
      • INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME

        static final java.lang.String INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • AgentLoader

        AgentLoader()
    • Method Detail

      • getVirtualMachineClass

        private static java.lang.Class<?> getVirtualMachineClass()
                                                          throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • getPossibleToolsJars

        private static java.util.List<java.io.File> getPossibleToolsJars()
      • loadAgent

        static boolean loadAgent()
        Attempts to load the agent through the Attach API
        Returns:
        true if agent was loaded (which could have happened thought the -javaagent switch)
      • warnIfOSX

        private static void warnIfOSX()
      • getAgentFile

        private static java.io.File getAgentFile()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • agentIsAvailable

        static boolean agentIsAvailable()
        Checks whether the agent is available
        Returns:
        true if available
      • agentSizeOf

        static long agentSizeOf​(java.lang.Object obj)
        Returns the size of this Java object as calculated by the loaded agent.
        Parameters:
        obj - object to be sized
        Returns:
        size of the object in bytes