alhudz opened a new pull request, #1828: URL: https://github.com/apache/commons-lang/pull/1828
1. `MemberUtils.isMatchingExecutable` takes the varargs branch for any varargs method or constructor. Its fixed-parameter loop stops at `parameterTypes.length`, so it never checks that the fixed parameters got enough arguments. `f(String, String, String...)` matches a single `String`, and `intStringVarArg(int, String...)` or `String.format(String, Object...)` match zero arguments. JLS 15.12.2.4 requires at least n-1. 2. `getMatchingAccessibleMethod` and `getMatchingAccessibleConstructor` then return that member instead of null. `invokeMethod`, `invokeStaticMethod` and `invokeConstructor` hand it to `toVarArgs`, which throws `ArrayIndexOutOfBoundsException` from `System.arraycopy` instead of the documented `NoSuchMethodException`. For example, `MethodUtils.invokeStaticMethod(String.class, "format")` and `ConstructorUtils.invokeConstructor(VarArgsBean.class)` both fail this way. The varargs branch now runs only when `parameterTypes.length >= methodParameterTypes.length - 1`. Any call that could actually be invoked before still resolves the same way. `getMatchingMethod` already filters on the full parameter arrays, so the shared helper is the only site. The new assertions in `MethodUtilsTest` and `ConstructorUtilsTest` fail before the change (`ArrayIndexOutOfBoundsException`, and a non-null inapplicable constructor) and pass after it. Before you push a pull request, review this list: - [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project. - [x] Read the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) if you use Artificial Intelligence (AI). - [x] I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? Claude Code (Anthropic) wrote the patch and tests, and drafted this description; I reviewed all of it. - [x] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself. - [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process. -- 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]
