commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r984655 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
Date Thu, 12 Aug 2010 06:47:43 GMT
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.

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;
                     }
                 }
             }



Mime
View raw message