// Record the field in the map
if (executedInsn instanceof WriteInstruction) {
// Exclude certain field writes because of infrastructure needs, e.g., Event class field writes
- for (String str : EXCLUDED_FIELDS_WRITE_INSTRUCTIONS_STARTS_WITH_LIST) {
+ for (String str : EXCLUDED_FIELDS_READ_WRITE_INSTRUCTIONS_STARTS_WITH_LIST) {
if (fieldClass.startsWith(str)) {
return;
}
"sendEvent", "Object", "reference", "location", "app", "state", "log", "functionList", "objectList",
"eventList", "valueList", "settings", "printToConsole", "app1", "app2"};
private final static String[] EXCLUDED_FIELDS_CONTAINS_LIST = {"_closure"};
- private final static String[] EXCLUDED_FIELDS_WRITE_INSTRUCTIONS_STARTS_WITH_LIST = {"Event"};
+ private final static String[] EXCLUDED_FIELDS_READ_WRITE_INSTRUCTIONS_STARTS_WITH_LIST = {"Event"};
- private boolean isFieldExcluded(String field) {
- // Check against "starts-with" list
- for(String str : EXCLUDED_FIELDS_STARTS_WITH_LIST) {
- if (field.startsWith(str)) {
+ private boolean excludeThisForItStartsWith(String[] excludedStrings, String className) {
+ for (String excludedField : excludedStrings) {
+ if (className.startsWith(excludedField)) {
return true;
}
}
- // Check against "ends-with" list
- for(String str : EXCLUDED_FIELDS_ENDS_WITH_LIST) {
- if (field.endsWith(str)) {
+ return false;
+ }
+
+ private boolean excludeThisForItEndsWith(String[] excludedStrings, String className) {
+ for (String excludedField : excludedStrings) {
+ if (className.endsWith(excludedField)) {
return true;
}
}
- // Check against "contains" list
- for(String str : EXCLUDED_FIELDS_CONTAINS_LIST) {
- if (field.contains(str)) {
+ return false;
+ }
+
+ private boolean excludeThisForItContains(String[] excludedStrings, String className) {
+ for (String excludedField : excludedStrings) {
+ if (className.contains(excludedField)) {
return true;
}
}
+ return false;
+ }
+
+ private boolean isFieldExcluded(String field) {
+ // Check against "starts-with", "ends-with", and "contains" list
+ if (excludeThisForItStartsWith(EXCLUDED_FIELDS_STARTS_WITH_LIST, field) ||
+ excludeThisForItEndsWith(EXCLUDED_FIELDS_ENDS_WITH_LIST, field) ||
+ excludeThisForItContains(EXCLUDED_FIELDS_CONTAINS_LIST, field)) {
+ return true;
+ }
return false;
}
private final static String DO_CALL_METHOD = "doCall";
private final static String GET_PROPERTY_METHOD =
"invokeinterface org.codehaus.groovy.runtime.callsite.CallSite.callGetProperty";
- private final static String[] EXCLUDED_FIELDS_ITERATOR = {"java.util.LinkedHashMap"};
private ReadWriteSet getReadWriteSet(int currentChoice) {
// Do the analysis to get Read and Write accesses to fields
}
// Get the iterated object whose property is accessed
ElementInfo eiAccessObj = VM.getVM().getHeap().get(frameSlots[1]);
- // TODO: MIGHT NEED TO EXCLUDE OTHER UNRELATED OBJECTS!
- for (String excludedField : EXCLUDED_FIELDS_ITERATOR) {
- if (eiAccessObj.getClassInfo().getName().startsWith(excludedField)) {
- return;
- }
+ // We exclude library classes (they start with java, org, etc.) and some more
+ String objClassName = eiAccessObj.getClassInfo().getName();
+ if (excludeThisForItStartsWith(EXCLUDED_FIELDS_STARTS_WITH_LIST, objClassName) ||
+ excludeThisForItStartsWith(EXCLUDED_FIELDS_READ_WRITE_INSTRUCTIONS_STARTS_WITH_LIST, objClassName)) {
+ return;
}
// Extract fields from this object and put them into the read write
int numOfFields = eiAccessObj.getNumberOfFields();