On Tue, 1 Sep 2026 06:22:48 GMT, Yunbo Zhang <[email protected]> wrote:

> Please review this small fix.
> 
> `MethodHandles.foldArguments` throws an unspecified 
> `ArrayIndexOutOfBoundsException` for negative `pos` values. Extreme values 
> such as `Integer.MAX_VALUE` can also overflow the existing addition-based 
> bounds check.
> 
> **Fix:**
> 
> Reject invalid positions with `IllegalArgumentException` and include the 
> position in the error message. Use a subtraction-based bounds check to avoid 
> overflow, and document the valid range for `pos`.
> 
> **Testing:**
> 
> - Added regression tests.
> - `make test TEST=test/jdk/java/lang/invoke`: 198 passed, 4 excluded, 0 
> failed.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 1c05cd0d
Author:    Yunbo Zhang <[email protected]>
Committer: Jorn Vernee <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/1c05cd0d1ce63286de6686e70210c3978bee5cbc
Stats:     53 lines in 2 files changed: 40 ins; 3 del; 10 mod

8367022: MethodHandles.foldArguments throws unspecified 
ArrayIndexOutOfBoundsException for negative pos

Reviewed-by: jvernee, liach

-------------

PR: https://git.openjdk.org/jdk/pull/32618

Reply via email to