> 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).

Yunbo Zhang has updated the pull request incrementally with one additional 
commit since the last revision:

  8367022: MethodHandles.foldArguments throws unspecified 
ArrayIndexOutOfBoundsException for negative pos

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/32618/files
  - new: https://git.openjdk.org/jdk/pull/32618/files/d60090a3..92d73638

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=32618&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=32618&range=02-03

  Stats: 8 lines in 1 file changed: 2 ins; 0 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/32618.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32618/head:pull/32618

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

Reply via email to