Changeset 5:ba17cf80ca94 in rrlib_serialization-java


Ignore:
Timestamp:
14.12.2013 01:27:59 (6 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Bugfix for deep-copying of natively-serializable types without default constructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Serialization.java

    r3 r5  
    317317            return src; 
    318318        } 
    319         if (dest == null || dest.getClass() != type) { 
     319        boolean useNativeSerialization = Serializable.class.isAssignableFrom(type) && (!Copyable.class.isAssignableFrom(type)) && (!BinarySerializable.class.isAssignableFrom(type)); 
     320        if ((dest == null || dest.getClass() != type) && (!useNativeSerialization)) { 
    320321            try { 
    321322                dest = (T)type.newInstance(); 
     
    337338        } 
    338339        try { 
    339             if (Serializable.class.isAssignableFrom(type)) { 
    340                 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
    341                 ObjectOutputStream oos = new ObjectOutputStream(baos); 
    342                 oos.writeObject(src); 
    343                 oos.close(); 
    344                 baos.close(); 
    345                 ObjectInputStream ois = new ObjectInputStreamUsingPluginClassLoader(new ByteArrayInputStream(baos.toByteArray())); 
     340            if (useNativeSerialization) { 
     341                ObjectInputStream ois = new ObjectInputStreamUsingPluginClassLoader(new ByteArrayInputStream(toByteArray((Serializable)src))); 
    346342                dest = (T)ois.readObject(); 
    347343                ois.close(); 
Note: See TracChangeset for help on using the changeset viewer.