New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8300207: Add a pre-check for the number of canonical equivalent permutations in j.u.r.Pattern #12027
Conversation
…tations in j.u.r.Pattern
👋 Welcome back rgiulietti! A progress list of the required criteria for merging this PR into |
@rgiulietti The following label will be automatically applied to this pull request:
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. |
Webrevs
|
@@ -1095,6 +1096,9 @@ public static Pattern compile(String regex) { | |||
* Compiles the given regular expression into a pattern with the given | |||
* flags. | |||
* | |||
* <p>Setting {@link #CANON_EQ} among the flags may impose a moderate risk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a candidate for @apiNote
, same thing for the note added to CANON_EQ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The choice of a <p>
paragraph rather than @apiNote
is for consistency with similar commentary paragraphs in the specs of CASE_INSENSITIVE
, UNICODE_CASE
, and UNICODE_CHARACTER_CLASS
.
I have no problems in using @apiNote
instead, but then it would be better to apply the same for the other mentioned flags as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see your point and to use apiNote consistently would require "converting" some of the existing text to apiNote too.
I'm still mulling over Pattern.compile throwing OOME. An implNote is probably the right category for this, in which case it can start with "In the the JDK Reference Implementation ...". I assume the static Pattern.matches needs same, and also Pattern.matcher for the lazy compilation case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no hard limit for the number of combining marks in the Unicode specification, even though in practice it never reaches the implementation limit. A high number of combining marks is thus more akin to a a resource exhaustion condition than to anything else, IMO.
Even today, compilation of a pattern risks throwing an OOME anyway when trying to generate the permutations. Pre-emptively throwing an OOME just anticipates and extrapolates this behavior beyond the int
limit of array lengths.
Alternatively, compilation (greedy or lazy) could throw PatternSyntaxException
, although there is not really something wrong with syntax.
I'll add @implNote
to the other methods you mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CSR will be updated once this PR stabilizes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had previously discussed with @rgiulietti whether OOME or PatternSyntaxException was more appropriate. The issue is that you might try to compile a pattern that contains a character with N combining diacritics, and it might work fine. But if you change that character to have N+1 combining diacritics, it might throw OOME. There's no syntax difference, but rather the issue is hitting an internal implementation limit.
There's a bit of a precedent for throwing OOME in such cases. Various places in the library try to grow arrays. If the required array size is greater than MAX_VALUE, the library pre-emptively throws OOME without even trying to allocate the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"In the the JDK Reference Implementation ..."
I'm still not sure of the right style for the JDK to refer to itself. This is really the "Java SE Reference Implementation". Or perhaps it should just be "OpenJDK". Regardless, this kind of wording would stick out in a funny way, as it's not used very frequently. I'm content not having such a preamble. Having the text within @implNote
is probably sufficient.
…tations in j.u.r.Pattern
The CSR is ready for review. |
@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:
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 128 new commits pushed to the
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 |
/integrate |
Going to push as commit 030b071.
Your commit was automatically rebased without conflicts. |
@rgiulietti Pushed as commit 030b071. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12027/head:pull/12027
$ git checkout pull/12027
Update a local copy of the PR:
$ git checkout pull/12027
$ git pull https://git.openjdk.org/jdk pull/12027/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12027
View PR using the GUI difftool:
$ git pr show -t 12027
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12027.diff