Skip to content
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

8316879: RegionMatches1Tests fails if CompactStrings are disabled after JDK-8302163 #15906

Closed
wants to merge 6 commits into from

Conversation

voitylov
Copy link

@voitylov voitylov commented Sep 25, 2023

test java.lang.String.RegionMatches1Tests fails on all platforms with -XX:-CompactStrings option and on ARM32 where Compact Strings is disabled by default. The fix is to return true immediately if len is negative, since for negative length this condition will never be satisfied.

Testing: JCK, JTREG passed with the fix with -XX:-CompactStrings on x86_64 and on ARM32.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)

Issue

  • JDK-8316879: RegionMatches1Tests fails if CompactStrings are disabled after JDK-8302163 (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15906

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 25, 2023

👋 Welcome back avoitylov! 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 Sep 25, 2023
@openjdk
Copy link

openjdk bot commented Sep 25, 2023

@voitylov 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 Sep 25, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 25, 2023

Webrevs

Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

Nice catch. I don't think a negative length should have ever been allowed in the first place, but this is Java 1.0 legacy ...

Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

Looks good.

PS: I specifically like the "Looks simple and harmless" comment on the PR of the original change :)

@simonis
Copy link
Member

simonis commented Sep 25, 2023

Might be a good idea to add a simple regressions test.

@openjdk
Copy link

openjdk bot commented Sep 25, 2023

@voitylov 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:

8316879: RegionMatches1Tests fails if CompactStrings are disabled after JDK-8302163

Reviewed-by: simonis, rgiulietti, rriggs

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 61 new commits pushed to the master branch:

  • ca5eee2: 8316445: Mark com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java as vm.flagless
  • 060db1b: 8315031: YoungPLABSize and OldPLABSize not aligned by ObjectAlignmentInBytes
  • 3481a48: 8316974: ListFormat creation is unsuccessful for some of the supported Locales
  • 29348b3: 8316894: make test TEST="jtreg:test/jdk/..." fails on AIX
  • 3f19df6: 8315936: Parallelize gc/stress/TestStressG1Humongous.java test
  • fc98998: 8316580: HttpClient with StructuredTaskScope does not close when a task fails
  • 065203d: 8313631: SA: stack trace printed using "where" command does not show class name
  • 0c55887: 8309599: WeakHandle and OopHandle release should clear obj pointer
  • 1230aed: 8316885: jcmd: Compiler.CodeHeap_Analytics cmd does not inform about missing aggregate
  • d0c1444: 8316957: Serial: Change GenCollectedHeap to SerialHeap inside gc/serial folder
  • ... and 51 more: https://git.openjdk.org/jdk/compare/0f0c5b2d71e6dec442a5105ba305043cb59b99fc...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@simonis, @rgiulietti, @RogerRiggs) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 25, 2023
@AlanBateman
Copy link
Contributor

/reviewers 2 reviewer

@AlanBateman
Copy link
Contributor

As Volker said, a test should be added. Also please have a maintainer working in this area review it too.

@openjdk
Copy link

openjdk bot commented Sep 26, 2023

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 26, 2023
Co-authored-by: Raffaello Giulietti <raffaello.giulietti@oracle.com>
@voitylov
Copy link
Author

@rgiulietti @simonis @AlanBateman thank you for the suggestions!

test/jdk/java/lang/String/RegionMatches.java was converted to testng and split into two @tests, the latter now covers 8316879.

Comment on lines 2160 to 2162
if (len < 0) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it also true that the regions trivial match if len == 0?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you are right. The statement "there is some nonnegative integer k less than len " covers the case len == 0, and the rest of the cases are checked before this line.

@RogerRiggs
Copy link
Contributor

test/jdk/java/lang/String/RegionMatches.java was converted to testng and split into two @tests, the latter now covers 8316879.

Can the test use JUnit 5? JUnit is being maintained compared to TestNG.

@mlbridge
Copy link

mlbridge bot commented Sep 26, 2023

Mailing list message from Raffaello Giulietti on core-libs-dev:

Since the tests are now TestNG, I think it would make more sense to use
TestNG `assertTrue` rather than using explicit `if`s and `throw`s.

On 2023-09-26 16:09, Aleksei Voitylov wrote:

@rgiulietti
Copy link
Contributor

I second @RogerRiggs' note that JUnit is better maintained than TestNG.

@rgiulietti
Copy link
Contributor

LGTM (but I'm not an official Reviewer)

@rgiulietti
Copy link
Contributor

Just out of curiosity: why not write, e.g.,

private final String s1_UTF16 = "\u043d\u0430\u0436\u0434";
private final String s2_UTF16 = "\u0432\u0020\u0441\u0442";

@voitylov
Copy link
Author

\u0XXX\u0XXX\u0XXX just seems harder to read, but maybe it's just me. I don't have a strong opinion on this, let me know if you believe what you suggest somehow improves readability or is more standard.

@rgiulietti
Copy link
Contributor

It avoids the two String constructor invocations, otherwise it is as (badly) readable as with the byte[].
My question was just curiosity.

The best thing would be to use "нажд" and "в ст", but AFAIK that's not allowed in OpenJDK.

Comment on lines 40 to 41
private final byte[] b1_UTF16 = new byte[]{0x04, 0x3d, 0x04, 0x30, 0x04, 0x36, 0x04, 0x34};
private final byte[] b2_UTF16 = new byte[]{0x04, 0x32, 0x00, 0x20, 0x04, 0x41, 0x04, 0x42};
Copy link
Contributor

Choose a reason for hiding this comment

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

For strings, the \uxxxx version would be preferred; it is clearer that what the character is and there is less of a chance that the UTF encoding has a mistake.

Copy link
Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the junit and unicode encoding changes.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 27, 2023
Copy link
Contributor

@rgiulietti rgiulietti left a comment

Choose a reason for hiding this comment

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

(not an official Reviewer)

@voitylov
Copy link
Author

voitylov commented Sep 28, 2023

/integrate

@voitylov
Copy link
Author

Thanks everyone for prompt reviews! Could someone sponsor this? I also intend to backport to 21u soon.

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Sep 28, 2023
@openjdk
Copy link

openjdk bot commented Sep 28, 2023

@voitylov
Your change (at version aa5faea) is now ready to be sponsored by a Committer.

@RogerRiggs
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 28, 2023

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

  • ca5eee2: 8316445: Mark com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java as vm.flagless
  • 060db1b: 8315031: YoungPLABSize and OldPLABSize not aligned by ObjectAlignmentInBytes
  • 3481a48: 8316974: ListFormat creation is unsuccessful for some of the supported Locales
  • 29348b3: 8316894: make test TEST="jtreg:test/jdk/..." fails on AIX
  • 3f19df6: 8315936: Parallelize gc/stress/TestStressG1Humongous.java test
  • fc98998: 8316580: HttpClient with StructuredTaskScope does not close when a task fails
  • 065203d: 8313631: SA: stack trace printed using "where" command does not show class name
  • 0c55887: 8309599: WeakHandle and OopHandle release should clear obj pointer
  • 1230aed: 8316885: jcmd: Compiler.CodeHeap_Analytics cmd does not inform about missing aggregate
  • d0c1444: 8316957: Serial: Change GenCollectedHeap to SerialHeap inside gc/serial folder
  • ... and 51 more: https://git.openjdk.org/jdk/compare/0f0c5b2d71e6dec442a5105ba305043cb59b99fc...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 28, 2023

@RogerRiggs @voitylov Pushed as commit cfcbfc6.

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

@voitylov
Copy link
Author

/backport jdk21u

@openjdk
Copy link

openjdk bot commented Sep 29, 2023

@voitylov the backport was successfully created on the branch voitylov-backport-cfcbfc6c in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit cfcbfc6c from the openjdk/jdk repository.

The commit being backported was authored by Aleksei Voitylov on 28 Sep 2023 and was reviewed by Volker Simonis, Raffaello Giulietti and Roger Riggs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git voitylov-backport-cfcbfc6c:voitylov-backport-cfcbfc6c
$ git checkout voitylov-backport-cfcbfc6c
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git voitylov-backport-cfcbfc6c

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.

6 participants