|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectInstrument
public class Instrument extends Object implements ClassFileTransformer
The Instrument class is responsible for modifying another class's bytecode. It changes calls to specified functions into static calls to user functions. This allows a user of Randoop to capture arbitrary calls and modify them as desired. For example, all calls to JOptionPane.showConfirmDialog (which would otherwise hang a regressions test) can be changed to throw an exception, or simply print a message and continue.
| Modifier and Type | Field and Description |
|---|---|
static SimpleLog |
debug_instrument
|
static SimpleLog |
debug_instrument_inst
|
static SimpleLog |
debug_map
Debug information on method maping |
static SimpleLog |
debug_transform
Debug information about which classes are transformed and why |
protected InstructionFactory |
ifact
|
static List<Instrument.MethodMapInfo> |
map_list
List of all classname regexs and their corresponding method maps |
| Constructor and Description |
|---|
Instrument()
|
| Modifier and Type | Method and Description |
|---|---|
void |
add_map_file_shutdown_hook()
Adds a shutdown hook that prints out the results of the method maps |
static void |
dump_map_list()
Dumps out the map list to the debug_map logger |
String |
get_attribute_name(Attribute a)
Returns the attribute name for the specified attribute |
void |
instrument_method(Method m,
MethodGen mg)
Instrument the specified method to replace mapped calls. |
boolean |
is_local_variable_type_table(Attribute a)
|
void |
read_map_file(File map_file)
Reads the file that specifies method calls that should be replaced by other method calls. |
protected static void |
replace_instructions(InstructionList il,
InstructionHandle ih,
InstructionList new_il)
Replace instruction ih in list il with the instructions in new_il. |
byte[] |
transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
Given another class, return a transformed version of the class which replaces specified calls with alternative static implementations |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected InstructionFactory ifact
public static SimpleLog debug_transform
public static SimpleLog debug_instrument
public static SimpleLog debug_instrument_inst
public static SimpleLog debug_map
public static List<Instrument.MethodMapInfo> map_list
| Constructor Detail |
|---|
public Instrument()
| Method Detail |
|---|
public byte[] transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException
transform in interface ClassFileTransformerIllegalClassFormatException
public void instrument_method(Method m,
MethodGen mg)
protected static void replace_instructions(InstructionList il,
InstructionHandle ih,
InstructionList new_il)
public boolean is_local_variable_type_table(Attribute a)
public String get_attribute_name(Attribute a)
public void read_map_file(File map_file)
throws IOException
IOExceptionpublic static void dump_map_list()
public void add_map_file_shutdown_hook()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||