class TransformFieldAccess extends Transformer {
    private String newClassname, newFieldname;
    private String fieldname;
    private CtClass fieldClass;
    private boolean isPrivate;

    /* cache */
    private int newIndex;
    private ConstPool constPool;

    public TransformFieldAccess(Transformer next, CtField field,
                                String newClassname, String newFieldname)
    {
        super(next);
        this.fieldClass = field.getDeclaringClass();
        this.fieldname = field.getName();
        this.isPrivate = Modifier.isPrivate(field.getModifiers());
        this.newClassname = newClassname;
        this.newFieldname = newFieldname;
        this.constPool = null;
    }

    @Override
    public void initialize(ConstPool cp, CodeAttribute attr) {
        if (constPool != cp)
            newIndex = 0;
    }

    /**
     * Modify GETFIELD, GETSTATIC, PUTFIELD, and PUTSTATIC so that
     * a different field is accessed.  The new field must be declared
     * in a superclass of the class in which the original field is
     * declared.
     */
    @Override
    public int transform(CtClass clazz, int pos,
                         CodeIterator iterator, ConstPool cp)
    {<FILL_FUNCTION_BODY>}
}

        int c = iterator.byteAt(pos);
        if (c == GETFIELD || c == GETSTATIC
                                || c == PUTFIELD || c == PUTSTATIC) {
            int index = iterator.u16bitAt(pos + 1);
            String typedesc
                = TransformReadField.isField(clazz.getClassPool(), cp,
                                fieldClass, fieldname, isPrivate, index);
            if (typedesc != null) {
                if (newIndex == 0) {
                    int nt = cp.addNameAndTypeInfo(newFieldname,
                                                   typedesc);
                    newIndex = cp.addFieldrefInfo(
                                        cp.addClassInfo(newClassname), nt);
                    constPool = cp;
                }

                iterator.write16bit(newIndex, pos + 1);
            }
        }

        return pos;
    
<methods>public void <init>(org.hotswap.agent.javassist.convert.Transformer) ,public void clean() ,public int extraLocals() ,public int extraStack() ,public org.hotswap.agent.javassist.convert.Transformer getNext() ,public void initialize(org.hotswap.agent.javassist.bytecode.ConstPool, org.hotswap.agent.javassist.bytecode.CodeAttribute) ,public void initialize(org.hotswap.agent.javassist.bytecode.ConstPool, org.hotswap.agent.javassist.CtClass, org.hotswap.agent.javassist.bytecode.MethodInfo) throws org.hotswap.agent.javassist.CannotCompileException,public abstract int transform(org.hotswap.agent.javassist.CtClass, int, org.hotswap.agent.javassist.bytecode.CodeIterator, org.hotswap.agent.javassist.bytecode.ConstPool) throws org.hotswap.agent.javassist.CannotCompileException, org.hotswap.agent.javassist.bytecode.BadBytecode<variables>private org.hotswap.agent.javassist.convert.Transformer next