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: r984655 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
Date Mon, 16 Aug 2010 09:50:23 GMT
On 12 August 2010 07:47,  <joehni@apache.org> wrote:
> Author: joehni
> Date: Thu Aug 12 06:47:43 2010
> New Revision: 984655
>
> URL: http://svn.apache.org/viewvc?rev=984655&view=rev
> Log:
> Fix wrong cast.

What was wrong with the cast?

>
> Modified:
>    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
>
> Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
> URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java?rev=984655&r1=984654&r2=984655&view=diff
> ==============================================================================
> --- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
(original)
> +++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
Thu Aug 12 06:47:43 2010
> @@ -265,14 +265,13 @@ public class ConstructorUtils {
>         }
>         Constructor<T> result = null;
>         /*
> -         * Class.getConstructors() is documented to return Constructor<T>
so as
> -         * long as the array is not subsequently modified, everything's fine:
> +         * (1) Class.getConstructors() is documented to return Constructor<T>
so as
> +         * long as the array is not subsequently modified, everything's fine.
>          */
> -        @SuppressWarnings("unchecked") // cls is of type T
> -        Constructor<T>[] ctors = cls.getConstructors();
> +        Constructor<?>[] ctors = cls.getConstructors();
>
>         // return best match:
> -        for (Constructor<T> ctor : ctors) {
> +        for (Constructor<?> ctor : ctors) {
>             // compare parameters
>             if (ClassUtils.isAssignable(parameterTypes, ctor.getParameterTypes(),
true)) {
>                 // get accessible version of constructor
> @@ -282,7 +281,10 @@ public class ConstructorUtils {
>                     if (result == null
>                             || MemberUtils.compareParameterTypes(ctor.getParameterTypes(),
result
>                                     .getParameterTypes(), parameterTypes)
< 0) {
> -                        result = ctor;
> +                        // temporary variable for annotation, see comment
above (1)
> +                        @SuppressWarnings("unchecked")
> +                        Constructor<T> constructor = (Constructor<T>)ctor;
> +                        result = constructor;
>                     }
>                 }
>             }
>
>
>

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


Mime
View raw message