public ClassFile clone() {
    ClassFile res=null;
    try {
      res=(ClassFile)super.clone(); // clone all primitive members

      // clone containers
      res.Items=new HashMap<Object,Integer>(res.Items);
      res.UTFs=new HashMap<String,Integer>(res.UTFs);
      res.paramsVars=(int [])res.paramsVars.clone();
      res.branchStack=res.branchStack.copy();

      if (Debug.enabled)
        Debug.check(cstk.length==6);
      res.cstk=new IntegerStack[6];
      for(int i=0;i<6;i++)
        res.cstk[i]=cstk[i].copy();

      // clone streams
      res.constPoolData=new ByteArrayOutputStream();
      constPool.flush();
      constPoolData.writeTo(res.constPoolData);
      res.constPool=new DataOutputStream(res.constPoolData);

      res.text=(byte[]) res.text.clone();
      
    } catch (IOException exc) {
      if (Debug.enabled)
        Debug.reportThrowable(exc);
    } catch (CloneNotSupportedException exc) {
      if (Debug.enabled)
        Debug.reportThrowable(exc);
    };
    return res;
  };