You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by Derek-Ashmore <gi...@git.apache.org> on 2016/05/13 09:50:01 UTC

[GitHub] commons-lang pull request: Lang 1195: Enhance MethodUtils to allow...

GitHub user Derek-Ashmore opened a pull request:

    https://github.com/apache/commons-lang/pull/141

    Lang 1195: Enhance MethodUtils to allow invocation of private methods

    Currently, MethodUtils is restricted to finding and invoking accessible methods. Frequently, developers have a need to test 'private' methods. What I see is that they escalate access to 'protected' in order to more easily provide test coverage for these methods. From a design perspective, this is bad.
    
    I propose to enhance MethodUtils so that it can easily invoke private methods. I'm not suggesting that developers should do this in production code, merely test code. Much as FieldUtils provides access to private fields via the 'forceAccess' overload on many of its methods. I've copied a utility like this around for years. It would be much more convenient to simply include it with Commons Lang. See [LANG-1195](https://issues.apache.org/jira/browse/LANG-1195) for details.
    
    I made sure that I used space indentation and tried to adhere closely to your standards.  I've also signed the Contributor License Agreement.
    
    Assuming you like the enhancement, I'm willing to contribute additional work if you see issues with what I've done.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Force66/commons-lang LANG-1195

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/141.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #141
    
----
commit f53fb65535232962ccd35ba9ad66e2e4c248f92e
Author: Derek Ashmore <da...@force66.com>
Date:   2016-01-01T14:31:47Z

    See LANG-1195; Enhance MethodUtils to allow invocation of private
    methods

commit 4a256e62529fbc57dfb55a99e222ec3591cee7ec
Author: Derek Ashmore <da...@force66.com>
Date:   2016-05-13T09:42:32Z

    See LANG-1195; Removed accidental tab indentation

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Hi Derek,
    
    sorry for the delay.
    
    I took another look at the code and compared it with `FieldUitls`. Maybe it is a good idea to change the method parameter order to `Object object, String methodName, boolean forceAccess`. I think `object` and `methodName` belong together and this order is similar to the order of the parameters of `FieldUtils` methods e.g. `FieldUtils#readDeclaredField(Object target, String fieldName, boolean forceAccess)`.
    
    What do you think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    @Derek-Ashmore Just today I learned that the resetting of the original accessibility of the method I asked you to add is not necessary, because `Method#setAccessible` only modifies the behavior of the `AccessibleObject` not of the actual method. 
    
    See http://stackoverflow.com/questions/10638826/java-reflection-impact-of-setaccessibletrue and http://www.artima.com/weblogs/viewpost.jsp?thread=164042 for details.
    
    Sorry that I caused you extra work. :(


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65728446
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -92,6 +92,29 @@ public static Object invokeMethod(final Object object, final String methodName)
                 IllegalAccessException, InvocationTargetException {
             return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null);
         }
    +    
    +    /**
    +     * <p>Invokes a named method without parameters.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    Yeah -- my bad. I'll correct the javadoc link. Thanks for catching that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Agreed -- in addition to the other changes you mentioned, I'll re-base using the current master so that it's easier to merge in.   Thanks for looking at this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    You are right. I missed that. It is impossible to use the parameter order I suggested, because it would clash with the existing `invokeMethod` signature. Sorry.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    It's the Objects.deepEquals() -- to new for the supported jdk versions -- I'll remove 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    I happened to notice that I inadvertently made unwanted formatting changes in a previous commit. I've take pains to reduce the number of changed lines dramatically. Hopefully, this will make it easier to merge this change into the trunk if it's decided that this is a reasonable enhancement.
    
    I'm also willing to make additional changes to the if you would like; anything I can do to make this contribution easier to merge in. 
    
    Please let me know if you have questions.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Good idea -- the change has been made and checked in.  Any other thoughts?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65721245
  
    --- 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 --
    
    For `FieldUtils` there is this jira issue: https://issues.apache.org/jira/browse/LANG-965?jql=project%20%3D%20LANG%20AND%20status%20%3D%20Open%20ORDER%20BY%20priority%20DESC "FieldUtils methods leak accessible flags" with requests that the visibility of a field should be restored after the field is written. Maybe the visibility of the method should also be restored after it is invoked? What do think? 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65720235
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -126,13 +149,41 @@ public static Object invokeMethod(final Object object, final String methodName,
         /**
          * <p>Invokes a named method whose parameter type matches the object type.</p>
          *
    -     * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
    +     * <p>This method supports calls to methods taking primitive parameters 
    +     * via passing in wrapping classes. So, for example, a {@code Boolean} object
    +     * would match a {@code boolean} primitive.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    I guess this should be ``invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object[] args, Class[] parameterTypes)`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65719370
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -126,13 +149,41 @@ public static Object invokeMethod(final Object object, final String methodName,
         /**
          * <p>Invokes a named method whose parameter type matches the object type.</p>
          *
    -     * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
    +     * <p>This method supports calls to methods taking primitive parameters 
    +     * via passing in wrapping classes. So, for example, a {@code Boolean} object
    +     * would match a {@code boolean} primitive.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    I guess this should be ``invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object[] args, Class[] parameterTypes)`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request: Lang 1195: Enhance MethodUtils to allow...

Posted by sebbASF <gi...@git.apache.org>.
Github user sebbASF commented on the pull request:

    https://github.com/apache/commons-lang/pull/141#issuecomment-219006770
  
    Note that an alternative solution for testing private methods is to make them package-protected.
    (and document why they are not private!)
    
    The test code needs to access it from the same package, but that is not usually a problem.
    If necessary create a public method in the same package which can be used by all the test code.
    A similar approach can be used for private fields; create a package-protected getter.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65720267
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -92,6 +92,29 @@ public static Object invokeMethod(final Object object, final String methodName)
                 IllegalAccessException, InvocationTargetException {
             return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null);
         }
    +    
    +    /**
    +     * <p>Invokes a named method without parameters.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    I guess this should be ``invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object[] args, Class[] parameterTypes)`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Hi Pascal,
    
    I'm not sure I did the re-base part correctly.  Both my forked master and LANG-1195 have all changes we discussed and are based on the updated master.  All conflicts were resolved and "I think"; you've obviously done this more than I have and I trust your judgement.  Please let me know if you see problems with what I've done.  Thanks for looking at this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65719281
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -92,6 +92,29 @@ public static Object invokeMethod(final Object object, final String methodName)
                 IllegalAccessException, InvocationTargetException {
             return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null);
         }
    +    
    +    /**
    +     * <p>Invokes a named method without parameters.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    I guess this should be ``invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object[] args, Class[] parameterTypes)`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Hi Derek,
    
    the rebase is perfect. :+1: 
    
    I think resetting the accessibility of should be done in a finally block, so that it works even when the method invocation throws an exception. What do you think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request: Lang 1195: Enhance MethodUtils to allow...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the pull request:

    https://github.com/apache/commons-lang/pull/141#issuecomment-219016359
  
    Thanks for taking time to respond.  I should be challenged on the need 
    for this.  I grant your point-- over-exposing methods is technically 
    possible.  I've issues with that, however.
    
     From an design perspective, you should only expose fields (through 
    accessors/mutators) and methods you intend to expose.  That is, that are 
    being made available for use by other classes or by inheritance. 
    Over-exposing methods and fields in the way you describe violates OO 
    design principles.  Creating an easy way for test code to access 
    privates is less of a principle breach; test classes presumably know 
    exactly how a class is supposed to operate and are tightly coupled to 
    that class anyway.
    
    Why create FieldUtils?  That logic should also have been used to not 
    implement the methods on FieldUtils that allow you to manipulate private 
    fields. Doesn't that run into the same issue?
    
    I don't like over-exposing fields and methods just to be able to cover 
    them in testing.  I'm not alone.
    
    Thanks for taking a look at this request and taking time to comment.  
    Thanks, also, for the most interesting discussion.
    Derek <https://www.linkedin.com/in/derekashmore> 
    <https://twitter.com/Derek_Ashmore> <http://www.derekashmore.com/>
    Please note that my email address has changed to 
    derek.ashmore@dvtconsulting.com
    On 5/13/2016 5:23 AM, sebbASF wrote:
    >
    > Note that an alternative solution for testing private methods is to 
    > make them package-protected.
    > (and document why they are not private!)
    >
    > The test code needs to access it from the same package, but that is 
    > not usually a problem.
    > If necessary create a public method in the same package which can be 
    > used by all the test code.
    > A similar approach can be used for private fields; create a 
    > package-protected getter.
    >
    > \u2014
    > You are receiving this because you authored the thread.
    > Reply to this email directly or view it on GitHub 
    > <https://github.com/apache/commons-lang/pull/141#issuecomment-219006770>
    >
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by Derek-Ashmore <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request: Lang 1195: Enhance MethodUtils to allow...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the pull request:

    https://github.com/apache/commons-lang/pull/141#issuecomment-221935416
  
    I agree.
    
    FieldUtils supports accessing private fields, so MethodUtils should support accessing private methods.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Hi Derek,
    
    you should be able to rebase this pull request by following these steps:
    * `git remote add upstream https://github.com/apache/commons-lang.git`
    * `git checkout master`
    * `git pull --rebase upstream`
    * `git checkout LANG-1195`
    * `git rebase master`
    * edit/resolve conflicts
    * `git rebase --continue`
    * `git push -f`
    
    Now this pull request is rebased onto master.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Thanks! :+1:


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Thank you! Without your pull request suggestion and additional support, it never would have gone anywhere. Please let me know if I can ever return the favor.
    
    
    
    On Jun 5, 2016, 1:57 PM, at 1:57 PM, Pascal Schumacher <no...@github.com> wrote:
    >Thanks! :+1:
    >
    >---
    >You are receiving this because you authored the thread.
    >Reply to this email directly or view it on GitHub:
    >https://github.com/apache/commons-lang/pull/141#issuecomment-223830424



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/commons-lang/pull/141


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    No worries \u2013 thanks for the information.
    
     
    
    From: Pascal Schumacher [mailto:notifications@github.com] 
    Sent: Saturday, October 22, 2016 9:49 AM
    To: apache/commons-lang <co...@noreply.github.com>
    Cc: Derek C. Ashmore <de...@dvtconsulting.com>; Mention <me...@noreply.github.com>
    Subject: Re: [apache/commons-lang] Lang 1195: Enhance MethodUtils to allow invocation of private methods (#141)
    
     
    
    @Derek-Ashmore <https://github.com/Derek-Ashmore>  Just today I learned that the resetting of the original accessibility of the method I asked you to add is not necessary, because Method#setAccessible only modifies the behavior of the AccessibleObject not of the actual method. 
    
    See http://stackoverflow.com/questions/10638826/java-reflection-impact-of-setaccessibletrue and http://www.artima.com/weblogs/viewpost.jsp?thread=164042 for details.
    
    Sorry that I caused you extra work. :(
    
    \u2014
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub <https://github.com/apache/commons-lang/pull/141#issuecomment-255532731> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AJ_pDP1r1vK1MUSpFytMpy0JHViRt5wEks5q2iJkgaJpZM4Id3N4> .  <https://github.com/notifications/beacon/AJ_pDIplHx6TfTt0uk_Ok_o0Jj1-KUURks5q2iJkgaJpZM4Id3N4.gif> 
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    
    [![Coverage Status](https://coveralls.io/builds/6464031/badge)](https://coveralls.io/builds/6464031)
    
    Coverage increased (+0.02%) to 93.428% when pulling **6da3ccb703cdd3539a7ffdfd168a9cfeb25689a7 on Force66:LANG-1195** into **43a9bab8c010d66744ae02b2d26020a946235202 on apache:master**.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    Thanks for updating the pull request. :+1: 
    
    It would be nice if you could rebase on current master.
    
    Thanks,
    Pascal


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #141: Lang 1195: Enhance MethodUtils to allow invo...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/141#discussion_r65728224
  
    --- Diff: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java ---
    @@ -126,13 +149,41 @@ public static Object invokeMethod(final Object object, final String methodName,
         /**
          * <p>Invokes a named method whose parameter type matches the object type.</p>
          *
    -     * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
    +     * <p>This method supports calls to methods taking primitive parameters 
    +     * via passing in wrapping classes. So, for example, a {@code Boolean} object
    +     * would match a {@code boolean} primitive.</p>
    +     *
    +     * <p>This is a convenient wrapper for
    +     * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
    --- End diff --
    
    Yeah -- my bad.   I'll correct the javadoc link.  Thanks for catching that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #141: Lang 1195: Enhance MethodUtils to allow invocation ...

Posted by Derek-Ashmore <gi...@git.apache.org>.
Github user Derek-Ashmore commented on the issue:

    https://github.com/apache/commons-lang/pull/141
  
    I originally thought the same thing.  The problems is the "Object... args" support.  The fact that it's optional means that you can put an optional boolean at the end easily and tell the difference between its intended use to force access or as an argument to the method.  Fields don't have args, so there's no ... support. See example below. 
    
    invokeMethod(final Object object, final String methodName, Object... args)
    invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object... args)
    
    We *could* put it at the end in the example below, but then it's inconsistent with the other overload:
    invokeMethod(final Object object, final boolean forceAccess, final String methodName, Object[] args, Class<?>[] parameterTypes)
    
    Am I missing something obvious?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---