package net.sf.cglib.transform;

import org.objectweb.asm.*;

public class TransformerChain extends ClassTransformer {
    private ClassTransformer[] chain;
    
    public TransformerChain(ClassTransformer[] chain) {
        this.chain = cloneAndLink(chain);
    }

    private static ClassTransformer[] cloneAndLink(ClassTransformer[] chain) {
        ClassTransformer[] copy = new ClassTransformer[chain.length];
        ClassVisitor cv = null;
        for (int i = chain.length - 1; i >= 0; i--) {
            copy[i] = (ClassTransformer)chain[i].clone();
            copy[i].setTarget(cv);
            cv = copy[i];
        }
        return copy;
    }

    public void setTarget(ClassVisitor v) {
        super.setTarget(chain[0]);
        chain[chain.length - 1].setTarget(v);
    }

    public Object clone() {
        TransformerChain t = (TransformerChain)super.clone();
        t.chain = cloneAndLink(chain);
        return t;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("TransformerChain{");
        for (int i = 0; i < chain.length; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(chain[i].toString());
        }
        sb.append("}");
        return sb.toString();
    }
}

@@ -776,32 +776,129 @@
 rget(v);%0A    %7D%0A%0A
+    public ClassVisitor getTarget() %7B%0A        return chain%5Bchain.length - 1%5D.getTarget();%0A    %7D%0A%0A
     public Objec

fix getTarget