Package daikon.dcomp
Class DCInstrument
- Object
-
- StackMapUtils
-
- InstructionListUtils
-
- DCInstrument
-
public class DCInstrument extends InstructionListUtils
Instruments a class file to perform Dynamic Comparability.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DCInstrument.JUnitState
Possible states of JUnit test discovery.
-
Field Summary
Fields Modifier and Type Field Description protected static Type[]
boolean_arg
protected static Type[]
CharSequence_arg
protected static Type[]
class_str
protected boolean
constructor_is_initialized
Has an<init>
method completed initialization?protected ObjectType
dcomp_marker
protected @DotSeparatedIdentifiers String
dcomp_prefix
Either "java.lang" or "daikon.dcomp".protected @DotSeparatedIdentifiers String
dcompRuntimeClassName
Either "daikon.dcomp.DCRuntime" or "java.lang.DCRuntime".protected static SimpleLog
debug_dup
Log file if debug_dup is enabled.protected static SimpleLog
debug_native
Log file if debug_native is enabled.protected static boolean
debugGetDefiningInterface
If true, enablegetDefiningInterface(org.apache.bcel.classfile.JavaClass, java.lang.String, org.apache.bcel.generic.Type[])
debugging.protected static boolean
debugHandleInvoke
If true, enablehandleInvoke(org.apache.bcel.generic.InvokeInstruction)
debugging.protected static boolean
debugJUnitAnalysis
If true, enable JUnit analysis debugging.protected static Type[]
double_arg
protected static Type[]
float_arg
protected ClassGen
gen
ClassGen for the current class.protected static String
GET_TAG
Name prefix for tag getter methods.protected static InstructionList
global_catch_il
protected static CodeExceptionGen
global_exception_handler
protected InstructionFactory
ifact
The BCEL InstructionFactory for generating byte code instructions.protected boolean
in_jdk
Is the current class a member of the JDK?protected static @BinaryName String
instrumentation_interface
Either "java.lang.DCompInstrumented" or "daikon.dcomp.DCompInstrumented".protected static Type[]
integer_arg
protected static Type
javalangClass
protected static ObjectType
javalangObject
protected static boolean
jdk_instrumented
Specifies if we are to use an instrumented version of the JDK.protected static boolean
junit_parse_seen
Have we seen 'JUnitCommandLineParseResult.parse'?protected static DCInstrument.JUnitState
junit_state
Current state of JUnit test discovery.protected static Set<String>
junitTestClasses
Set of JUnit test classes.protected @Nullable ClassLoader
loader
The loader that loaded the Class to instrument.protected static Type[]
long_arg
protected MethodGen
mgen
MethodGen for the current method.protected static DCInstrument.MethodDef[]
obj_methods
List of Object methods.protected static Type[]
object_arg
protected static Type
object_arr
protected static Type[]
object_int
protected static Type[]
object_string
protected JavaClass
orig_class
Unmodified version of input class.static boolean
quit_if_error
Used when testing to continue processing if an error occurs.protected static String
SET_TAG
Name prefix for tag setter methods.protected static Type[]
short_arg
protected List<String>
skipped_methods
Keeps track of the methods that were not successfully instrumented.protected static Type[]
string_arg
protected LocalVariableGen
tag_frame_local
Local that stores the tag frame for the current method.protected static ObjectType
throwable
protected static Type[]
two_ints
protected static Type[]
two_objects
protected static String[]
uninit_classes
Array of classes whose fields are not initialized from java.
-
Constructor Summary
Constructors Constructor Description DCInstrument(JavaClass orig_class, boolean in_jdk, @Nullable ClassLoader loader)
Initialize with the original class and whether or not the class is part of the JDK.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add_create_tag_frame(MethodGen mg)
Adds the code to create the tag frame to the beginning of the method.void
add_enter(MethodGen mg, MethodInfo mi, int method_info_index)
Adds the call to DCRuntime.enter to the beginning of the method.void
add_exception_handler(MethodGen mg, InstructionList catch_il)
Adds a try/catch block around the entire method.void
build_exception_handler(MethodGen mg)
Adds a try/catch block around the entire method.protected String
full_name(JavaClass jc, Field f)
Return the fully qualified fieldname of the specified field.List<String>
get_skipped_methods()
Returns the list of uninstrumented methods.void
install_exception_handler(MethodGen mg)
Adds a try/catch block around the entire method.JavaClass
instrument()
Instruments the original class to perform dynamic comparabilty and returns the new class definition.JavaClass
instrument_jdk()
Instruments a JDK class to perform dynamic comparability and returns the new class definition.void
instrument_method(MethodGen mg)
Instrument the specified method for dynamic comparability.protected String
simplify_method_name(Method m)
Return simplified name of a method.-
Methods inherited from class InstructionListUtils
append_inst, build_il, calculateLiveLocalTypes, calculateLiveStackTypes, delete_instructions, insertAtMethodStart, insertBeforeHandle, replaceInstructions
-
Methods inherited from class StackMapUtils
addNewParameter, addString, adjust_code_for_locals_change, bcelCalcStackTypes, buildUninitializedNewMap, create_local_from_live_range, create_method_scope_local, createNewStackMapAttribute, findStackMapEqual, findStackMapIndexAfter, findStackMapIndexBefore, fixLocalVariableTable, gen_locals, gen_locals_from_byte_codes, gen_locals_from_byte_codes, generate_Type_from_StackMapType, generateStackMapTypeFromType, get_attribute_name, get_local_variable_type_table_attribute, getSize, getStackMapTable_attribute, is_local_variable_type_table, isStackMapTable, modifyStackMapsForSwitches, printStackMapTable, remove_local_variable_type_table, set_method_stackTypes, setCurrentStackMapTable, typeToClassGetName, update_full_frameStackMap_entries, updateStackMapOffset, updateUninitializedNewOffsets
-
-
-
-
Field Detail
-
quit_if_error
public static boolean quit_if_error
Used when testing to continue processing if an error occurs. Currently, This flag is only used by BuildJDK.
-
orig_class
protected JavaClass orig_class
Unmodified version of input class.
-
gen
protected ClassGen gen
ClassGen for the current class.
-
mgen
protected MethodGen mgen
MethodGen for the current method.
-
in_jdk
protected boolean in_jdk
Is the current class a member of the JDK?
-
ifact
protected InstructionFactory ifact
The BCEL InstructionFactory for generating byte code instructions.
-
loader
protected @Nullable ClassLoader loader
The loader that loaded the Class to instrument.
-
constructor_is_initialized
protected boolean constructor_is_initialized
Has an<init>
method completed initialization?
-
tag_frame_local
protected LocalVariableGen tag_frame_local
Local that stores the tag frame for the current method.
-
two_objects
protected static Type[] two_objects
-
object_string
protected static Type[] object_string
-
two_ints
protected static Type[] two_ints
-
object_int
protected static Type[] object_int
-
string_arg
protected static Type[] string_arg
-
integer_arg
protected static Type[] integer_arg
-
float_arg
protected static Type[] float_arg
-
double_arg
protected static Type[] double_arg
-
boolean_arg
protected static Type[] boolean_arg
-
long_arg
protected static Type[] long_arg
-
short_arg
protected static Type[] short_arg
-
object_arg
protected static Type[] object_arg
-
CharSequence_arg
protected static Type[] CharSequence_arg
-
javalangClass
protected static Type javalangClass
-
class_str
protected static Type[] class_str
-
object_arr
protected static Type object_arr
-
throwable
protected static ObjectType throwable
-
dcomp_marker
protected ObjectType dcomp_marker
-
javalangObject
protected static ObjectType javalangObject
-
debug_native
protected static SimpleLog debug_native
Log file if debug_native is enabled.
-
debug_dup
protected static SimpleLog debug_dup
Log file if debug_dup is enabled.
-
debugJUnitAnalysis
protected static final boolean debugJUnitAnalysis
If true, enable JUnit analysis debugging.- See Also:
- Constant Field Values
-
debugGetDefiningInterface
protected static final boolean debugGetDefiningInterface
If true, enablegetDefiningInterface(org.apache.bcel.classfile.JavaClass, java.lang.String, org.apache.bcel.generic.Type[])
debugging.- See Also:
- Constant Field Values
-
debugHandleInvoke
protected static final boolean debugHandleInvoke
If true, enablehandleInvoke(org.apache.bcel.generic.InvokeInstruction)
debugging.- See Also:
- Constant Field Values
-
skipped_methods
protected List<String> skipped_methods
Keeps track of the methods that were not successfully instrumented.
-
jdk_instrumented
protected static boolean jdk_instrumented
Specifies if we are to use an instrumented version of the JDK. Calls into the JDK must be modified to remove the arguments from the tag stack if the JDK is not instrumented. This flag is set/reset in daikon.dcomp.Premain.
-
instrumentation_interface
protected static @BinaryName String instrumentation_interface
Either "java.lang.DCompInstrumented" or "daikon.dcomp.DCompInstrumented".
-
dcomp_prefix
protected @DotSeparatedIdentifiers String dcomp_prefix
Either "java.lang" or "daikon.dcomp".
-
dcompRuntimeClassName
protected @DotSeparatedIdentifiers String dcompRuntimeClassName
Either "daikon.dcomp.DCRuntime" or "java.lang.DCRuntime".
-
SET_TAG
protected static final String SET_TAG
Name prefix for tag setter methods.- See Also:
- Constant Field Values
-
GET_TAG
protected static final String GET_TAG
Name prefix for tag getter methods.- See Also:
- Constant Field Values
-
junitTestClasses
protected static Set<String> junitTestClasses
Set of JUnit test classes.
-
junit_state
protected static DCInstrument.JUnitState junit_state
Current state of JUnit test discovery.
-
junit_parse_seen
protected static boolean junit_parse_seen
Have we seen 'JUnitCommandLineParseResult.parse'?
-
uninit_classes
protected static String[] uninit_classes
Array of classes whose fields are not initialized from java. Since the fields are not initialized from java, their tag storage is not allocated as part of a store, but rather must be allocated as part of a load. We call a special runtime method for this so that we can check for this in other cases.
-
obj_methods
protected static DCInstrument.MethodDef[] obj_methods
List of Object methods. Since we can't instrument Object, none of these can be instrumented, and most of them don't provide useful comparability information anyway. The equals method and the clone method are special-cased in thehandleInvoke(org.apache.bcel.generic.InvokeInstruction)
routine.
-
global_catch_il
protected static InstructionList global_catch_il
-
global_exception_handler
protected static CodeExceptionGen global_exception_handler
-
-
Constructor Detail
-
DCInstrument
public DCInstrument(JavaClass orig_class, boolean in_jdk, @Nullable ClassLoader loader)
Initialize with the original class and whether or not the class is part of the JDK.
-
-
Method Detail
-
instrument
public JavaClass instrument()
Instruments the original class to perform dynamic comparabilty and returns the new class definition.- Returns:
- the modified JavaClass
-
instrument_jdk
public JavaClass instrument_jdk()
Instruments a JDK class to perform dynamic comparability and returns the new class definition. A second version of each method in the class is created which is instrumented for comparability.- Returns:
- the modified JavaClass
-
instrument_method
public void instrument_method(MethodGen mg)
Instrument the specified method for dynamic comparability.- Parameters:
mg
- MethodGen for the method to be instrumented
-
get_skipped_methods
public List<String> get_skipped_methods()
Returns the list of uninstrumented methods. (Note: instrument_jdk() needs to have been called first.)
-
build_exception_handler
public void build_exception_handler(MethodGen mg)
Adds a try/catch block around the entire method. If an exception occurs, the tag stack is cleaned up and the exception is rethrown.
-
add_exception_handler
public void add_exception_handler(MethodGen mg, InstructionList catch_il)
Adds a try/catch block around the entire method.
-
install_exception_handler
public void install_exception_handler(MethodGen mg)
Adds a try/catch block around the entire method.
-
add_create_tag_frame
public void add_create_tag_frame(MethodGen mg)
Adds the code to create the tag frame to the beginning of the method. This needs to be before the call to DCRuntime.enter (since it passed to that method).
-
add_enter
public void add_enter(MethodGen mg, MethodInfo mi, int method_info_index)
Adds the call to DCRuntime.enter to the beginning of the method.- Parameters:
mg
- method to modifymi
- MethodInfo for methodmethod_info_index
- index for MethodInfo
-
full_name
protected String full_name(JavaClass jc, Field f)
Return the fully qualified fieldname of the specified field.- Parameters:
jc
- class containing the fieldf
- the field- Returns:
- string containing the fully qualified name
-
simplify_method_name
protected String simplify_method_name(Method m)
Return simplified name of a method. Both exceptions and annotations are removed.- Parameters:
m
- the method- Returns:
- string containing the simplified method name
-
-