commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r989199 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/SerializationUtils.java test/java/org/apache/commons/lang3/SerializationUtilsTest.java
Date Wed, 25 Aug 2010 21:46:43 GMT
On 25 August 2010 17:15,  <mbenson@apache.org> wrote:
> Author: mbenson
> Date: Wed Aug 25 16:15:44 2010
> New Revision: 989199
>
> URL: http://svn.apache.org/viewvc?rev=989199&view=rev
> Log:
> make SerializationUtils.clone() type-safe
>
> Modified:
>    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
>    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
>
> Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
> URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java?rev=989199&r1=989198&r2=989199&view=diff
> ==============================================================================
> --- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
(original)
> +++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
Wed Aug 25 16:15:44 2010
> @@ -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")

Why is it safe to suppress the warning?

Please can you add a // comment to explain the reason?

> +    public static <T extends Serializable> T clone(T object) {
> +        return (T) deserialize(serialize(object));
>     }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message