public class Agent extends java.lang.Object implements IObjectSizeProvider, IRecordingEndListener
-javaagent:location-of-instrumentation-jar=parameter
whereby the parameters are described in here.
| Modifier and Type | Class and Description |
|---|---|
private static class |
Agent.JarProvider
Implements an on-creation jar provider which returns
jars. |
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.instrument.Instrumentation |
instrumentation
Stores the instrumentation instance.
|
private static java.lang.String[] |
jars
Stores the additional jars to be added to a newly created class pool.
|
private static HashMap<java.lang.String,java.lang.Object> |
RETRANSFORM
Stores the class names to be retransformed by default.
|
private static MonitoringClassFileTransformer |
transformer
Stores the transformer in order to provide convenient
removal of the transformer.
|
| Modifier | Constructor and Description |
|---|---|
private |
Agent()
Prevents this class from being called from outside.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
agentmain(java.lang.String args,
java.lang.instrument.Instrumentation inst)
JVM hook to dynamically load javaagent at runtime.
|
private static void |
appendToPath(java.lang.instrument.Instrumentation inst,
java.lang.String fileName,
boolean bootpath)
Appends the given jar file in
fileName either to the boot
class path or to the system class path. |
long |
getObjectSize(java.lang.Object object)
Returns the size of the given object as allocated by the JVM.
|
static void |
initialize()
Programmatic hook to dynamically load javaagent at runtime.
|
private static void |
initialize(java.lang.String args,
java.lang.instrument.Instrumentation inst)
Initialize this agent with the given instrumentation.
|
void |
notifyRecordingEnd()
Is called when recording ends.
|
static void |
premain(java.lang.String agentArgs,
java.lang.instrument.Instrumentation inst)
JVM hook to statically load the javaagent at startup.
|
static void |
removeTransformer()
Removes the transformer attached to this agent.
|
static void |
retransformLoadedClasses(HashMap<java.lang.String,?> classNames,
boolean doLibTransformation)
Attempts to retransform already loaded classes.
|
private static java.lang.instrument.Instrumentation instrumentation
private static MonitoringClassFileTransformer transformer
private static java.lang.String[] jars
private static final HashMap<java.lang.String,java.lang.Object> RETRANSFORM
private Agent()
public static void premain(java.lang.String agentArgs,
java.lang.instrument.Instrumentation inst)
After the Java Virtual Machine (JVM) has initialized, the premain method will be called. Then the real application main method will be called.
agentArgs - the arguments for the agentinst - the instrumentation instancepublic static void removeTransformer()
public static void agentmain(java.lang.String args,
java.lang.instrument.Instrumentation inst)
throws java.lang.Exception
The agent class may have an agentmain method for use when the agent is started after VM startup.
args - the arguments for the agentinst - the instrumentation instancejava.lang.Exception - in case of unexpected behaviorprivate static void appendToPath(java.lang.instrument.Instrumentation inst,
java.lang.String fileName,
boolean bootpath)
fileName either to the boot
class path or to the system class path.inst - the instrumenter to appendfileName - the jar file namebootpath - append to the boot class path true or to
the system class path falseprivate static void initialize(java.lang.String args,
java.lang.instrument.Instrumentation inst)
args - the arguments for the agentinst - the instrumentation instancepublic static void retransformLoadedClasses(HashMap<java.lang.String,?> classNames, boolean doLibTransformation)
classNames - the class names to be retransformed (cleared as a
side effect)doLibTransformation - do Java library transformations if
requiredpublic static void initialize()
public long getObjectSize(java.lang.Object object)
getObjectSize in interface IObjectSizeProviderobject - the object the size should be queried forobject
(in bytes, negative or zero if invalid or not available,
always 0)public void notifyRecordingEnd()
notifyRecordingEnd in interface IRecordingEndListener