com.google.testing.threadtester
Class TestInstrumenter
java.lang.Object
com.google.testing.threadtester.TestInstrumenter
- All Implemented Interfaces:
- Instrumenter, ClassFileTransformer
public class TestInstrumenter
- extends Object
- implements Instrumenter, ClassFileTransformer
An Instrumenter that transforms a class' bytecode in order to add tracing
calls to a CallLogger. The tracing can be used to create Breakpoints that allow the execution of this class to be
suspended.
A TestInstrumenter is normally invoked via an InstrumentedClassLoader. If tesst are run
using a BaseThreadedTestRunner, this is handled automatically. In
addition, a TestInstrumenter implements the ClassFileTransformer interface, so that it can be used
to instrument classes as they are loaded by the system classloader.
- Author:
- alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
|
Constructor Summary |
TestInstrumenter(List<String> classes)
Creates a new TestInstrumenter that will instrumented the given list of
named classes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GET_METHOD
protected static final String GET_METHOD
- See Also:
- Constant Field Values
METHOD_TABLE
protected static final String METHOD_TABLE
- See Also:
- Constant Field Values
LOGGER
protected static final String LOGGER
- See Also:
- Constant Field Values
TestInstrumenter
public TestInstrumenter(List<String> classes)
- Creates a new TestInstrumenter that will instrumented the given list of
named classes. These names should be in the format returned by
Class.getName().
premain
public static void premain(String agentArgument,
Instrumentation instrumentation)
- The premain method that will be invoked if the TestInstrumenter is used in
conjunction with the -javaagent command-line option. See the package
documentation for java.lang.instrument.
- Parameters:
agentArgument - a comma-separated list of classnames to instrumentinstrumentation - the JVM's instrumentation service.
transform
public byte[] transform(ClassLoader loader,
String className,
Class clss,
ProtectionDomain domain,
byte[] bytes)
- Specified by:
transform in interface ClassFileTransformer
instrument
public byte[] instrument(String className,
byte[] bytes)
- Description copied from interface:
Instrumenter
- Transforms an array of bytes that defines a class.
- Specified by:
instrument in interface Instrumenter
- Parameters:
className - the name of the class being defined.bytes - the bytes that make up the class data.
- Returns:
- the transformed bytecode. A given Instrumenter may chose not to
transform all classes, in which case it may just return the given
classData.
Copyright © 2013. All Rights Reserved.