Class AllocationInstrumenter
- java.lang.Object
-
- com.google.monitoring.runtime.instrumentation.AllocationInstrumenter
-
- All Implemented Interfaces:
java.lang.instrument.ClassFileTransformer
public class AllocationInstrumenter extends java.lang.Object implements java.lang.instrument.ClassFileTransformerInstruments bytecodes that allocate heap memory to call a recording hook. This will add a static invocation to a recorder function to any bytecode that looks like it will be allocating heap memory allowing users to implement heap profiling schemes.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]instrument(byte[] originalBytes, java.lang.ClassLoader loader)static byte[]instrument(byte[] originalBytes, java.lang.String recorderClass, java.lang.String recorderMethod, java.lang.ClassLoader loader)Given the bytes representing a class, go through all the bytecode in it and instrument any occurrences of new/newarray/anewarray/multianewarray with pre- and post-allocation hooks.static voidpremain(java.lang.String agentArgs, java.lang.instrument.Instrumentation inst)byte[]transform(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] origBytes)
-
-
-
Method Detail
-
premain
public static void premain(java.lang.String agentArgs, java.lang.instrument.Instrumentation inst)
-
transform
public byte[] transform(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] origBytes)- Specified by:
transformin interfacejava.lang.instrument.ClassFileTransformer
-
instrument
public static byte[] instrument(byte[] originalBytes, java.lang.String recorderClass, java.lang.String recorderMethod, java.lang.ClassLoader loader)Given the bytes representing a class, go through all the bytecode in it and instrument any occurrences of new/newarray/anewarray/multianewarray with pre- and post-allocation hooks. Even more fun, intercept calls to the reflection API's Array.newInstance() and instrument those too.- Parameters:
originalBytes- the originalbyte[]code.recorderClass- theStringinternal name of the class containing the recorder method to run.recorderMethod- theStringname of the recorder method to run.loader- theClassLoaderfor this class.- Returns:
- the instrumented
byte[]code.
-
instrument
public static byte[] instrument(byte[] originalBytes, java.lang.ClassLoader loader)- Parameters:
originalBytes- The original version of the class.loader- The ClassLoader of this class.- Returns:
- the instrumented version of this class.
- See Also:
documentation for the 4-arg version. This is a convenience version that uses the recorder in this class.
-
-