make SerializationUtils.clone() type-safe

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@989199 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2010-08-25 16:15:44 +00:00
parent 52bea417c5
commit c3e3feeaa1
2 changed files with 4 additions and 3 deletions

View File

@ -77,8 +77,9 @@ public class SerializationUtils {
* @return the cloned object
* @throws SerializationException (runtime) if the serialization fails
*/
public static Object clone(Serializable object) {
return deserialize(serialize(object));
@SuppressWarnings("unchecked")
public static <T extends Serializable> T clone(T object) {
return (T) deserialize(serialize(object));
}
// Serialize

View File

@ -340,7 +340,7 @@ public class SerializationUtilsTest extends TestCase {
//-----------------------------------------------------------------------
public void testClone() throws Exception {
Object test = SerializationUtils.clone(iMap);
HashMap<?, ?> test = SerializationUtils.clone(iMap);
assertNotNull(test);
assertTrue(test instanceof HashMap<?,?>);
assertTrue(test != iMap);