public class ModifiedSystemClassRuntime extends AbstractRuntime
IRuntime
implementation works with a modified system class. A
new static field is added to a bootstrap class that will be used by
instrumented classes. As the system class itself needs to be instrumented
this runtime requires a Java agent.data
Constructor and Description |
---|
ModifiedSystemClassRuntime(Class<?> systemClass,
String accessFieldName)
Creates a new runtime based on the given class and members.
|
Modifier and Type | Method and Description |
---|---|
static IRuntime |
createFor(Instrumentation inst,
String className)
Creates a new
ModifiedSystemClassRuntime using the given class as
the data container. |
static IRuntime |
createFor(Instrumentation inst,
String className,
String accessFieldName)
Creates a new
ModifiedSystemClassRuntime using the given class as
the data container. |
int |
generateDataAccessor(long classid,
String classname,
int probecount,
org.objectweb.asm.MethodVisitor mv)
This method generates the byte code required to obtain the coverage data
structure for the class with the given id.
|
static byte[] |
instrument(byte[] source,
String accessFieldName)
Adds the static data field to the given class definition.
|
void |
shutdown()
Allows the coverage runtime to cleanup internals.
|
void |
startup(RuntimeData data)
Subclasses must call this method when overwriting it.
|
createRandomId
public ModifiedSystemClassRuntime(Class<?> systemClass, String accessFieldName)
systemClass
- system class that contains the execution dataaccessFieldName
- name of the public static runtime access fieldpublic void startup(RuntimeData data) throws Exception
AbstractRuntime
startup
in interface IRuntime
startup
in class AbstractRuntime
data
- the execution data for this runtimeException
- any internal problem during startuppublic void shutdown()
IRuntime
public int generateDataAccessor(long classid, String classname, int probecount, org.objectweb.asm.MethodVisitor mv)
IExecutionDataAccessorGenerator
boolean[]
instance to the
operand stack. Except this result object the generated code must not make
any assumptions about the structure of the embedding method or class. The
generated code must not use or allocate local variables.classid
- identifier of the classclassname
- VM class nameprobecount
- probe count for this classmv
- code outputpublic static IRuntime createFor(Instrumentation inst, String className) throws ClassNotFoundException
ModifiedSystemClassRuntime
using the given class as
the data container. Member is created with internal default name. The
given class must not have been loaded before by the agent.inst
- instrumentation interfaceclassName
- VM name of the class to useClassNotFoundException
- id the given class can not be foundpublic static IRuntime createFor(Instrumentation inst, String className, String accessFieldName) throws ClassNotFoundException
ModifiedSystemClassRuntime
using the given class as
the data container. The given class must not have been loaded before by
the agent.inst
- instrumentation interfaceclassName
- VM name of the class to useaccessFieldName
- name of the added runtime access fieldClassNotFoundException
- id the given class can not be foundpublic static byte[] instrument(byte[] source, String accessFieldName)
source
- class definition sourceaccessFieldName
- name of the runtime access fieldCopyright © 2021. All rights reserved.