box.setValue(Jimple.v().newThisRef(
RefType.v(newClass)));
}
} else if (value instanceof ParameterRef) {
// Fix references to a parameter
ParameterRef r = (ParameterRef) value;
Type type = r.getType();
if (type instanceof RefType
&& (((RefType) type).getSootClass() == oldClass)) {
box.setValue(Jimple.v().newParameterRef(
RefType.v(newClass), r.getIndex()));
}
} else if (value instanceof InvokeExpr) {
// Fix up the method invokes.
InvokeExpr r = (InvokeExpr) value;
SootMethodRef methodRef = r.getMethodRef();
System.out.println("invoke = " + r);
List newParameterTypes = new LinkedList();
for (Iterator i = methodRef.parameterTypes().iterator(); i
.hasNext();) {
Type type = (Type) i.next();
if (type instanceof RefType
&& (((RefType) type).getSootClass() == oldClass)) {
System.out.println("matchedParameter = "
+ newClass);
newParameterTypes.add(RefType.v(newClass));
} else if (type instanceof RefType
&& (((RefType) type).getSootClass()
.getName().startsWith(oldClass
.getName()))) {
System.out.println("matchedParameter = "
+ newClass);
SootClass changeClass = _getInnerClassCopy(
oldClass, ((RefType) type)
.getSootClass(), newClass);
newParameterTypes.add(RefType.v(changeClass));
} else {
newParameterTypes.add(type);
}
}
Type newReturnType = methodRef.returnType();
if (newReturnType instanceof RefType
&& (((RefType) newReturnType).getSootClass() == oldClass)) {
newReturnType = RefType.v(newClass);
}
// Update the parameter types and the return type.
methodRef = Scene.v().makeMethodRef(
methodRef.declaringClass(), methodRef.name(),
newParameterTypes, newReturnType,
methodRef.isStatic());
r.setMethodRef(methodRef);
if (methodRef.declaringClass() == oldClass) {
r.setMethodRef(Scene.v().makeMethodRef(newClass,
methodRef.name(),
methodRef.parameterTypes(),
methodRef.returnType(),
methodRef.isStatic()));
// System.out.println("newValue = " +
// box.getValue());
} else if (methodRef.declaringClass().getName()
.startsWith(oldClass.getName())) {
SootClass changeClass = _getInnerClassCopy(
oldClass, methodRef.declaringClass(),
newClass);
r.setMethodRef(Scene.v().makeMethodRef(changeClass,
methodRef.name(),
methodRef.parameterTypes(),
methodRef.returnType(),
methodRef.isStatic()));
}
} else if (value instanceof NewExpr) {
// Fix up the object creations.
NewExpr r = (NewExpr) value;
if (r.getBaseType().getSootClass() == oldClass) {
r.setBaseType(RefType.v(newClass));
// System.out.println("newValue = " +
// box.getValue());
} else if (r.getBaseType().getSootClass().getName()
.startsWith(oldClass.getName())) {
SootClass changeClass = _getInnerClassCopy(
oldClass, r.getBaseType().getSootClass(),
newClass);
r.setBaseType(RefType.v(changeClass));
}
}
// System.out.println("value = " + value);
// System.out.println("class = " +