garydgregory commented on PR #1783:
URL: https://github.com/apache/commons-lang/pull/1783#issuecomment-5593205702

   I think this PR creates 2 bugs so it looks like we are missing some tests 
since the build was green, so please add these missing tests and update the 
main code:
   
   - At the new `getAccessibleMethod(cls, candidate)` call, a package-private 
subclass’s public static method can be replaced by a same-signature method on 
its public superclass. Static methods do not dispatch to subclass 
implementations.
   With `Child.who()` returning `"child"` and `Parent.who()` returning 
`"parent"`:
   `MethodUtils.invokeStaticMethod(Child.class, "who")`
   Before PR: `"child"`
   After PR:  `"parent"`
   So you should preserve the existing exact-match behavior for static 
candidates.
   
   - Reject static interface methods as replacements for instance methods.
   The interface lookup uses `getDeclaredMethod()` without excluding static 
methods. A public interface can declare `static String label()`, while its 
package-private implementing class independently declares an instance `String 
label()`.
   `MethodUtils.invokeMethod(instance, "label")`
   Before PR: `"instance"`
   After PR:  `"interface-static"`
   Reflection ignores the receiver when invoking that static method. Skipping 
resolution for static candidates alone does not fix this case: replacement 
declarations must also be checked.
   
   Note: Your AI is imagining things when it talks about PR 
https://github.com/apache/commons-lang/pull/1427 because that PR was closed 
without being merged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to