Cloneable VS SerializationUtils.clone()

  • seb

    seb - 2005-08-19

    Hi guys

    I was testing the newest release this morning, and found a problem related to classloader.
    As explained in the thread called "Dozer suggestions", i want to put common jars not in my WEB-INF/lib, but in another simple project (added to ws.ext.dirs). When i map 'simple' objects (with simple-type fields: String, int, ...), it works fine. But i have a more complex case that doesn't work :

    Consider a A class with a field named foo, of AFoo type.
    Consider a APrime class with a field named foo, of AFooPrime type.
    Here's my mapping :


    In this case, i get the following error message (printStackTrace()) :

    org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException: net.sf.dozer.util.mapping.fieldmap.FieldMap
    at org.apache.commons.lang.SerializationUtils.deserialize(

    Now, i change my mapping to :


    As you can see, foo fields aren't mapped at all. But this doesn't make any error at runtime ...

    To solve that, i made a few changes in Dozer sources :

    In, line 126, change :
      FieldMap fm = (FieldMap) SerializationUtils.clone(field);
    to :
      FieldMap fm = (FieldMap) field.clone();

    I have also changed, and to make them Cloneable. clone() methods are all like :

    public Object clone() throws
      CloneNotSupportedException {
        return super.clone();

    Conclusions :
    1. It works !! (of course ;-) )
    2. It's quicker like the former code. With this example, on a 1000 iterations loop, it's between 1.5 and 2 times faster.

    Ready for the next release ? ;-)


    • Ben Sullins

      Ben Sullins - 2005-08-19

      Thanks for the suggestions, we will test them out.

    • Franz Garsombke

      Franz Garsombke - 2005-08-19

      You sure you don't want to be on the dozer team :) ?

      I will test and put these fixes in today for you.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks