commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/reflect MethodUtils.java
Date Thu, 21 Nov 2002 19:38:52 GMT
rdonkin     2002/11/21 11:38:52

  Modified:    lang/src/java/org/apache/commons/lang/reflect
                        MethodUtils.java
  Log:
  Make MethodUtils depend on ReflectionUtils parameter set comparasons
  
  Revision  Changes    Path
  1.8       +21 -40    jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/MethodUtils.java
  
  Index: MethodUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/MethodUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MethodUtils.java	21 Nov 2002 18:53:32 -0000	1.7
  +++ MethodUtils.java	21 Nov 2002 19:38:51 -0000	1.8
  @@ -561,50 +561,31 @@
                   
                   // compare parameters
                   Class[] methodsParams = methods[i].getParameterTypes();
  -                int methodParamSize = methodsParams.length;
  -                if (methodParamSize == paramSize) {          
  -                    boolean match = true;
  -                    for (int n = 0 ; n < methodParamSize; n++) {
  +                if (ReflectionUtils.isCompatible(parameterTypes, methodsParams)) {
  +                    // get accessible version of method
  +                    Method method = getAccessibleMethod(methods[i]);
  +                    if (method != null) {
                           if (debug) {
  -                            log("Param=" + parameterTypes[n].getName());
  -                            log("Method=" + methodsParams[n].getName());
  +                            log(method + " accessible version of " 
  +                                        + methods[i]);
                           }
  -                        if (!ReflectionUtils.isCompatible(parameterTypes[n], methodsParams[n]))
{
  -                            if (debug) {
  -                                log(methodsParams[n] + " is not assignable from " 
  -                                            + parameterTypes[n]);
  -                            }    
  -                            match = false;
  -                            break;
  +                        try {
  +                            //
  +                            // XXX Default access superclass workaround
  +                            // (See above for more details.)
  +                            //
  +                            method.setAccessible(true);
  +                            
  +                        } catch (SecurityException se) {
  +                            // log but continue just in case the method.invoke works anyway
  +                            log(
  +                            "Cannot setAccessible on method. Therefore cannot use jvm access
bug workaround.", 
  +                            se);
                           }
  +                        return method;
                       }
                       
  -                    if (match) {
  -                        // get accessible version of method
  -                        Method method = getAccessibleMethod(methods[i]);
  -                        if (method != null) {
  -                            if (debug) {
  -                                log(method + " accessible version of " 
  -                                            + methods[i]);
  -                            }
  -                            try {
  -                                //
  -                                // XXX Default access superclass workaround
  -                                // (See above for more details.)
  -                                //
  -                                method.setAccessible(true);
  -                                
  -                            } catch (SecurityException se) {
  -                                // log but continue just in case the method.invoke works
anyway
  -                                log(
  -                                "Cannot setAccessible on method. Therefore cannot use jvm
access bug workaround.", 
  -                                se);
  -                            }
  -                            return method;
  -                        }
  -                        
  -                        log("Couldn't find accessible method.");
  -                    }
  +                    log("Couldn't find accessible method.");
                   }
               }
           }
  
  
  

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


Mime
View raw message