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

8280550: SplittableRandom#nextDouble(double,double) can return result >= bound #1478

Closed
wants to merge 3 commits into from

Conversation

GoeLin
Copy link
Member

@GoeLin GoeLin commented Oct 26, 2022

The original fix patches jdk/internal/util/random/RandomSupport.java.
This class is not in 11.

The Random code was completely reworked by
"8248862: Implement Enhanced Pseudo-Random Number Generators"
In the old 11 code there are several methods 'nextDouble' or
'internalNextDouble' all using the same pattern. They were
replaced by the implementation in the new class
RandomSupport in 17.

I adapted the following methods:
in java/util/Random.java:
final double internalNextDouble(double origin, double bound)

in java/util/SplittableRandom.java
final double internalNextDouble(double origin, double bound)
public double nextDouble(double bound)

in java/util/concurrent/ThreadLocalRandom.java
final double internalNextDouble(double origin, double bound)
public double nextDouble(double bound)

I think this are all affected methods, but please double-check.

The change requires follow-up 8280950 which needs to be
adapted to touch the three internalNextDouble()
methods.


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-8280550: SplittableRandom#nextDouble(double,double) can return result >= bound

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev pull/1478/head:pull/1478
$ git checkout pull/1478

Update a local copy of the PR:
$ git checkout pull/1478
$ git pull https://git.openjdk.org/jdk11u-dev pull/1478/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1478

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/1478.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 26, 2022

👋 Welcome back goetz! 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 changed the title Backport 0c42e43f77b91a50fedc3fddb74e17f910d8df2a 8280550: SplittableRandom#nextDouble(double,double) can return result >= bound Oct 26, 2022
@openjdk
Copy link

openjdk bot commented Oct 26, 2022

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Oct 26, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 26, 2022

Webrevs

Copy link
Member

@phohensee phohensee left a comment

Choose a reason for hiding this comment

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

There's similar code in java.desktop/share/classes/sun/awt/geom/Curve.java, but it hasn't been updated in tip, so lgtm.

@openjdk
Copy link

openjdk bot commented Nov 1, 2022

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

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

8280550: SplittableRandom#nextDouble(double,double) can return result >= bound

Reviewed-by: phh

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

  • 5c454ae: 8287826: javax/accessibility/4702233/AccessiblePropertiesTest.java fails to compile
  • b928a88: 8292899: CustomTzIDCheckDST.java testcase failed on AIX platform
  • 7067c7c: 8272123: Problem list 4 jtreg tests which regularly fail on macos-aarch64
  • 1f618ab: 8285373: Create an automated test for JDK-4702233
  • b9b5e52: 8273578: javax/swing/JMenu/4515762/bug4515762.java fails on macOS 12
  • 429cbc4: 8295288: Some vm_flags tests associate with a wrong BugID
  • 0b0529e: 8280948: Write a regression test for JDK-4659800
  • 0f08e3c: 8282402: Create a regression test for JDK-4666101
  • 5ecd16d: 8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
  • 18631ef: 8280158: New test from JDK-8274736 failed with/without patch in JDK11u
  • ... and 1 more: https://git.openjdk.org/jdk11u-dev/compare/3c1e0cf887336bcf74314b5cfd4a97c7cc12b91b...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 Nov 1, 2022
@GoeLin
Copy link
Member Author

GoeLin commented Nov 2, 2022

Good catch of this further appearance. I agree the fix is not needed there. But the methods there might not always deliver the previous double either.

@phohensee
Copy link
Member

Perhaps file a bug against tip, fix it, and backport.

@GoeLin
Copy link
Member Author

GoeLin commented Nov 3, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Nov 3, 2022

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

  • 82c9cf2: 8199290: [TESTBUG] sun.hotspot.WhiteBox$WhiteBoxPermission is not copied
  • 5c454ae: 8287826: javax/accessibility/4702233/AccessiblePropertiesTest.java fails to compile
  • b928a88: 8292899: CustomTzIDCheckDST.java testcase failed on AIX platform
  • 7067c7c: 8272123: Problem list 4 jtreg tests which regularly fail on macos-aarch64
  • 1f618ab: 8285373: Create an automated test for JDK-4702233
  • b9b5e52: 8273578: javax/swing/JMenu/4515762/bug4515762.java fails on macOS 12
  • 429cbc4: 8295288: Some vm_flags tests associate with a wrong BugID
  • 0b0529e: 8280948: Write a regression test for JDK-4659800
  • 0f08e3c: 8282402: Create a regression test for JDK-4666101
  • 5ecd16d: 8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
  • ... and 2 more: https://git.openjdk.org/jdk11u-dev/compare/3c1e0cf887336bcf74314b5cfd4a97c7cc12b91b...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 3, 2022

@GoeLin Pushed as commit 91f1538.

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

@GoeLin GoeLin deleted the goetz_backport_8280550 branch November 3, 2022 15:24
@GoeLin
Copy link
Member Author

GoeLin commented Nov 4, 2022

I opened JDK-8296402 for the pattern in Curve.java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
2 participants