Modify a method body so that an expression writing the specified field is replaced with a call to the specified static method. This static method receives two parameters: the target object of the original write expression and the assigned value. The return type of the static method is
void
.
For example, the program below
Point p = new Point(); p.x = 3;
can be translated into:
Point p = new Point(); Accessor.writeX(3);
where
public class Accessor { public static void writeX(Object target, int value) { ... } }
The type of the first parameter of writeX()
must be java.lang.Object
independently of the actual type of target
. The type of the second parameter is the same as the field type.
@param field the field.
@param calledClass the class in which the static method isdeclared.
@param calledMethod the name of the static method.