RFR: 8312976: MatchResult produces StringIndexOutOfBoundsException for groups outside match [v4]

Raffaello Giulietti rgiulietti at openjdk.org
Thu Aug 3 21:41:31 UTC 2023


On Mon, 31 Jul 2023 18:38:30 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Fixes a bug showing up after [JDK-8132995](https://bugs.openjdk.org/browse/JDK-8132995) when there are capturing groups outside the match.
>
> Raffaello Giulietti has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Merged with mainline.
>  - Merge branch 'master' into 8312976
>  - Refactored recent tests as JUnit parametrized test.
>  - Added a test with negatvie lookbehind.
>  - Added test with a lookahead containing a back reference.
>  - 8312976: MatchResult produces StringIndexOutOfBoundsException for groups outside match

Yes, I noticed that as well.

There's another [PR](https://git.openjdk.org/jdk/pull/14894) aimed to reduce the length of the `groups` array when possible (currently, it is always sized for at least 10 pairs of (`start`, `end`) entries, even when only one pair is needed for group 0). That one is slated for >= 22, so I might be coordinated the future PR for the removal of the redundant `first` and `last` fields with that PR.

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

PR Comment: https://git.openjdk.org/jdk/pull/15053#issuecomment-1664678223


More information about the core-libs-dev mailing list