ClassFileTransformer
public class ConstructorInstrumenter extends Object implements ClassFileTransformer
ConstructorCallback
s by
invoking instrumentClass(Class, ConstructorCallback)
.Modifier and Type | Method | Description |
---|---|---|
static byte[] |
instrument(byte[] originalBytes,
Class<?> classBeingRedefined) |
Given the bytes representing a class, add invocations of the
ConstructorCallback method to the constructor.
|
static void |
instrumentClass(Class<?> c,
ConstructorCallback<?> sampler) |
Ensures that the given sampler will be invoked every time a constructor
for class c is invoked.
|
static void |
invokeSamplers(Object o) |
Bytecode is rewritten to invoke this method; it calls the sampler for
the given class.
|
byte[] |
transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer) |
transform
public static void instrumentClass(Class<?> c, ConstructorCallback<?> sampler) throws UnmodifiableClassException
c
- The class to be trackedsampler
- the code to be invoked when an instance of c is constructedUnmodifiableClassException
- if c cannot be modified.public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
transform
in interface ClassFileTransformer
public static byte[] instrument(byte[] originalBytes, Class<?> classBeingRedefined)
originalBytes
- the original byte[]
code.classBeingRedefined
- the class being redefined.byte[]
code.public static void invokeSamplers(Object o)
o
- the object passed to the samplers.Copyright © 2009–2018 Google, Inc.. All rights reserved.