Skip to content

Conversation

@rgiulietti
Copy link
Contributor

@rgiulietti rgiulietti commented Jul 27, 2023

Fixes a bug showing up after JDK-8132995 when there are capturing groups outside the match.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8312976: MatchResult produces StringIndexOutOfBoundsException for groups outside match (Bug - P2)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15053/head:pull/15053
$ git checkout pull/15053

Update a local copy of the PR:
$ git checkout pull/15053
$ git pull https://git.openjdk.org/jdk.git pull/15053/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15053

View PR using the GUI difftool:
$ git pr show -t 15053

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15053.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 27, 2023

👋 Welcome back rgiulietti! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 27, 2023
@openjdk
Copy link

openjdk bot commented Jul 27, 2023

@rgiulietti The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jul 27, 2023
@rgiulietti
Copy link
Contributor Author

Once integrated in mainline, the fix should be backported to 21, where the bug was introduced.

@mlbridge
Copy link

mlbridge bot commented Jul 27, 2023

Webrevs

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay. I think its would be useful to get another reviewer to also look over this in case there is any other issues.

@openjdk
Copy link

openjdk bot commented Aug 2, 2023

@rgiulietti This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8312976: MatchResult produces StringIndexOutOfBoundsException for groups outside match

Reviewed-by: alanb, smarks

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 42 new commits pushed to the master branch:

  • 4577147: 8313712: [BACKOUT] 8313632: ciEnv::dump_replay_data use fclose
  • bb3aac6: 8301606: JFileChooser file chooser details view "size" label cut off in Metal Look&Feel
  • 0f2fce7: 8313632: ciEnv::dump_replay_data use fclose
  • ab1c212: 8312909: C1 should not inline through interface calls with non-subtype receiver
  • c386091: 8312984: javac may crash on a record pattern with too few components
  • 3212b64: 8313582: Problemlist failing test on linux x86
  • bdac348: 8313602: increase timeout for jdk/classfile/CorpusTest.java
  • 58906bf: 4893524: Swing drop targets should call close() on transferred readers and streams
  • 3c920f9: 8313274: [BACKOUT] Relax prerequisites for java.base-jmod target
  • 53ca75b: 8313312: Add missing classpath exception copyright header
  • ... and 32 more: https://git.openjdk.org/jdk/compare/5362ec9c6e9123d00288497ac9d1879a2bb1ca64...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 2, 2023
@stuart-marks
Copy link
Member

OK, changes and tests look good. Who knew, a capturing group could have bounds outside the matched string!

I did notice something that we might want to look at in the future. MatchResult has first and last fields; these seem redundant with the group[0] and group[1] entries. Indeed, Matcher also has first and last and the group[] array; start() returns first and end() returns last; while start(0) returns group[0] and end(0) returns group[1]. But the javadocs say that start() and start(0) are equivalent and that end() and end(0) are also equivalent. So Matcher also appears to have this redundancy. Since these values are all set by the matching engine in Pattern it seems like the redundancy is spread throughout the code.

Conceptually it might be possible for MatchResult to omit first and last and just use the first two group array entries, but it's really hard to verify this. Unclear whether this is worthwhile (and it's certainly not worth trying to include in this bugfix).

@rgiulietti
Copy link
Contributor Author

Yes, I noticed that as well.

There's another PR 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.

@rgiulietti
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 4, 2023

Going to push as commit 61c58fd.
Since your change was applied there have been 47 commits pushed to the master branch:

  • 5d23295: 8313251: Add NativeLibraryLoad event
  • c4b8574: 8311938: Add default cups include location for configure on AIX
  • 10a2605: 8294979: test/jdk/tools/jlink 3 test classes use ASM library
  • e8c325d: 8313394: Array Elements in OldObjectSample event has the incorrect description
  • d60352e: 8311006: missing @SInCE info in jdk.xml.dom
  • 4577147: 8313712: [BACKOUT] 8313632: ciEnv::dump_replay_data use fclose
  • bb3aac6: 8301606: JFileChooser file chooser details view "size" label cut off in Metal Look&Feel
  • 0f2fce7: 8313632: ciEnv::dump_replay_data use fclose
  • ab1c212: 8312909: C1 should not inline through interface calls with non-subtype receiver
  • c386091: 8312984: javac may crash on a record pattern with too few components
  • ... and 37 more: https://git.openjdk.org/jdk/compare/5362ec9c6e9123d00288497ac9d1879a2bb1ca64...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 4, 2023
@openjdk openjdk bot closed this Aug 4, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 4, 2023
@openjdk
Copy link

openjdk bot commented Aug 4, 2023

@rgiulietti Pushed as commit 61c58fd.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@rgiulietti rgiulietti deleted the 8312976 branch November 27, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants