Github user Derek-Ashmore commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65728344
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java 
---
    @@ -142,21 +193,57 @@ public static Object invokeMethod(final Object 
object, final String methodName,
          * @throws InvocationTargetException wraps an exception thrown by the 
method invoked
          * @throws IllegalAccessException if the requested method is not 
accessible via reflection
          */
    -    public static Object invokeMethod(final Object object, final String 
methodName,
    +    public static Object invokeMethod(final Object object, final boolean 
forceAccess, final String methodName,
                 Object[] args, Class<?>[] parameterTypes)
                 throws NoSuchMethodException, IllegalAccessException,
                 InvocationTargetException {
             parameterTypes = ArrayUtils.nullToEmpty(parameterTypes);
             args = ArrayUtils.nullToEmpty(args);
    -        final Method method = 
getMatchingAccessibleMethod(object.getClass(),
    -                methodName, parameterTypes);
    +        
    +        final String messagePrefix;
    +        final Method method;
    +        if (forceAccess) {
    +            messagePrefix = "No such method: ";
    +            method = getMatchingMethod(object.getClass(), methodName, 
parameterTypes);
    +            if (method != null) {
    +                method.setAccessible(true);
    --- End diff --
    
    Agreed -- I didn't realize that the issue was out there and wanted to be 
consistent with FieldUtils.   I'll make this change.   Thanks for making me 
aware of it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to