I am trying to implement a DeepClone using traits. I borrows the implementation from this stackoverflow answer

Is there a way to bypass the generated proxy? Or other implementation that can avoid this error? My simplistic test code is as follow
(The real case is a map of lists, that's why I need a deep-clone)

Thanks in advance.

trait DeepCloneable {
    // implementation adapted from http://stackoverflow.com/a/13155429/318102
    def deepClone() {
        def orig = this
        def bos = new ByteArrayOutputStream()
        def oos = new ObjectOutputStream(bos)
        oos.writeObject(orig); oos.flush()
        def bin = new ByteArrayInputStream(bos.toByteArray())
        def ois = new ObjectInputStream(bin)
        return ois.readObject()
    }
}

def map = [name: "Fernando"] as DeepCloneable
def clone = map.deepClone()