Package org.ehcache.sizeof.impl
Class AgentLoader
- java.lang.Object
-
- org.ehcache.sizeof.impl.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 Summary
Fields Modifier and Type Field Description private static java.lang.instrument.Instrumentation
instrumentation
(package private) static java.lang.String
INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME
private static org.slf4j.Logger
LOGGER
private static java.lang.String
SIZEOF_AGENT_CLASSNAME
private static java.lang.reflect.Method
VIRTUAL_MACHINE_ATTACH
private static java.lang.String
VIRTUAL_MACHINE_CLASSNAME
private static java.lang.reflect.Method
VIRTUAL_MACHINE_DETACH
private static java.lang.reflect.Method
VIRTUAL_MACHINE_LOAD_AGENT
-
Constructor Summary
Constructors Constructor Description AgentLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static boolean
agentIsAvailable()
Checks whether the agent is available(package private) static long
agentSizeOf(java.lang.Object obj)
Returns the size of this Java object as calculated by the loaded agent.private static java.io.File
getAgentFile()
private static java.util.List<java.io.File>
getPossibleToolsJars()
private static java.lang.Class<?>
getVirtualMachineClass()
(package private) static boolean
loadAgent()
Attempts to load the agent through the Attach APIprivate static void
warnIfOSX()
-
-
-
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
-
-
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
-
-