// A method has side effects if it sets the values of any fields.
Body body = method.retrieveActiveBody();
Scene.v().releaseActiveHierarchy();
for (Iterator units = body.getUnits().iterator(); units.hasNext();) {
Unit unit = (Unit) units.next();
if (_debug) {
System.out.println("unit = " + unit);
}
for (Iterator boxes = unit.getDefBoxes().iterator(); boxes
.hasNext();) {
ValueBox box = (ValueBox) boxes.next();
Value value = box.getValue();
if (value instanceof FieldRef) {
if (_debug) {
System.out
.println("SideEffectAnalysis: assigns to field");
}
out.addSideEffect(((FieldRef) value).getField());
}
if (value instanceof ArrayRef) {
if (_debug) {
System.out
.println("SideEffectAnalysis: assigns to array.");
}
// Escape analysis might help in this case.
out.setUnknownSideEffects();
return out;
}
}
// Method calls that are in the invokeGraph
// have already been checked.
// However, it turns out that context classes
// are not included in the
// invokeGraph! This checks to see if there
// are any invocations of
// methods that are not in the invoke graph. Conservatively
// assume that they have side effects.
for (Iterator boxes = unit.getUseBoxes().iterator(); boxes
.hasNext();) {
ValueBox box = (ValueBox) boxes.next();
Value expr = box.getValue();
if (expr instanceof InvokeExpr) {