Modify a method body so that an expression reading the specified field is replaced with a call to the specified
static method. This static method receives the target object of the original read expression as a parameter. It must return a value of the same type as the field.
For example, the program below
Point p = new Point(); int newX = p.x + 3;
can be translated into:
Point p = new Point(); int newX = Accessor.readX(p) + 3;
where
public class Accessor { public static int readX(Object target) { ... } }
The type of the parameter of readX()
must be java.lang.Object
independently of the actual type of target
. The return type must be 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.