Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes #151

Closed
wants to merge 8 commits into from

Conversation

JimLaskey
Copy link
Member

@JimLaskey JimLaskey commented Jun 25, 2021

The wording of the @implSpec referred to internal methods in the description. The patch rewords the @implSpec to be more descriptive of the algorithm than the methods used.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/151/head:pull/151
$ git checkout pull/151

Update a local copy of the PR:
$ git checkout pull/151
$ git pull https://git.openjdk.java.net/jdk17 pull/151/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 151

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/151.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 25, 2021

👋 Welcome back jlaskey! 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 Jun 25, 2021
@openjdk
Copy link

openjdk bot commented Jun 25, 2021

@JimLaskey 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.java.net label Jun 25, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 25, 2021

Webrevs

@JimLaskey
Copy link
Member Author

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 28, 2021
@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@JimLaskey this pull request must refer to an issue in JBS to be able to link it to a CSR request. To refer this pull request to an issue in JBS, please use the /issue command in a comment in this pull request.

* be greater equal zero and less than {@code bound}. If {@code bound} is a
* power of two then limiting is a simple masking operation. Otherwise, a
* new result is re-calculated by averaging the previous result and
* {@code nextInt()} until the final result is greater equal zero and less
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how 'averaging' comes from the invocation of boundedNextInt which appears to choose the first candidate that meets the criteria.
The comment also applies to nextLong overloads.

Copy link
Member Author

@JimLaskey JimLaskey Jun 28, 2021

Choose a reason for hiding this comment

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

If the first value calculated doesn't meet the criteria, then you either mask (power of 2) or go into this loop which does the averaging. The intent is not to bias the outcome.

                for (long u = r >>> 1;            // ensure nonnegative
                     u + m - (r = u % n) < 0L;    // rejection check
                     u = rng.nextLong() >>> 1) // retry
                    ;

Copy link
Member Author

@JimLaskey JimLaskey Jun 28, 2021

Choose a reason for hiding this comment

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

Yea you're right. I was focused on the divide by two, which appears to just remove the sign. Clearer interpretation:

r = rng.nextLong();
n = range;
m = n - 1;                   // mask
for (long u = r / 2;         // ensure nonnegative
     u + m < r;              // rejection check
     u = rng.nextLong() / 2) // retry
    r = u % n;

@JimLaskey
Copy link
Member Author

/help

@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey Available commands:

  • cc - add or remove an additional classification label
  • clean - Mark the backport pull request as a clean backport
  • contributor - adds or removes additional contributors for a PR
  • covered - used when employer has signed the OCA
  • csr - require a compatibility and specification request (CSR) for this pull request
  • help - shows this text
  • integrate - performs integration of the changes in the PR
  • issue - edit the list of issues that this PR solves
  • label - add or remove an additional classification label
  • open - Set the pull request state to "open"
  • reviewer - manage additional reviewers for a PR
  • reviewers - set the number of additional required reviewers for this PR
  • signed - used after signing the OCA
  • solves - edit the list of issues that this PR solves
  • sponsor - performs integration of a PR that is authored by a non-committer
  • summary - updates the summary in the commit message
  • test - used to run tests

@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey Command syntax:

  • /issue [add|remove] <id>[,<id>,...]
  • /issue [add] <id>: <description>
  • `/issue create [PX] /[subcomponent]

Some examples:

  • /issue add JDK-1234567,4567890
  • /issue remove JDK-4567890
  • /issue 1234567: Use this exact title
  • `/issue create hotspot/jfr
  • `/issue create P4 core-libs/java.nio

If issues are specified only by their ID, the title will be automatically retrieved from JBS. The project prefix (JDK- in the above examples) is optional. Separate multiple issue IDs using either spaces or commas.

@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey The issue 8266313 was not found in the JDK project - make sure you have entered it correctly.
The issue 8268770 was not found in the JDK project - make sure you have entered it correctly.
As there were validation problems, no additional issues will be added to the list of solved issues.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jun 28, 2021
@JimLaskey
Copy link
Member Author

/issue JDK-8266313 JDK-8268770

@openjdk openjdk bot changed the title JDK-8266313 (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes 8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes Jun 28, 2021
@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey This issue is referenced in the PR title - it will now be updated.

Adding additional issue to issue list: 8268770: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes.

@JimLaskey
Copy link
Member Author

/csr

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 28, 2021
@openjdk
Copy link

openjdk bot commented Jun 28, 2021

@JimLaskey this pull request will not be integrated until the CSR request JDK-8268770 for issue JDK-8266313 has been approved.

* the result to be greater equal {@code origin} and less than {@code bound}.
* If {@code bound} is a power of two then limiting is a simple masking
* operation. Otherwise, the result is re-calculated by invoking
* {@code nextInt()} until the result is greater equal {@code origin}
Copy link
Contributor

Choose a reason for hiding this comment

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

greater equal -> greater than or equal
and in the overloads below (and above)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

* {@link RandomSupport#checkBound checkBound}(bound) and then
* {@link RandomSupport#boundedNextInt boundedNextInt}(this, bound).
* @implSpec The default implementation checks that {@code bound} is a
* positive int. Then invokes {@code nextInt()}, limiting the result to
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you are refering to the Java type it should be in {@ code xxx }.
"int" - > {@ code int}. Or use "integer".
Ditto "ints", "long", and "longs" in the overridden methods below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

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.

Thanks for the updates.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jun 29, 2021
@JimLaskey
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 30, 2021

@JimLaskey This PR has not yet been marked as ready for integration.

@JimLaskey
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 12, 2021

@JimLaskey This PR has not yet been marked as ready for integration.

@JimLaskey
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

@JimLaskey This PR has not yet been marked as ready for integration.

@JimLaskey
Copy link
Member Author

/help

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

@JimLaskey Available commands:

  • cc - add or remove an additional classification label
  • clean - Mark the backport pull request as a clean backport
  • contributor - adds or removes additional contributors for a PR
  • covered - used when employer has signed the OCA
  • csr - require a compatibility and specification request (CSR) for this pull request
  • help - shows this text
  • integrate - performs integration of the changes in the PR
  • issue - edit the list of issues that this PR solves
  • label - add or remove an additional classification label
  • open - Set the pull request state to "open"
  • reviewer - manage additional reviewers for a PR
  • reviewers - set the number of additional required reviewers for this PR
  • signed - used after signing the OCA
  • solves - edit the list of issues that this PR solves
  • sponsor - performs integration of a PR that is authored by a non-committer
  • summary - updates the summary in the commit message
  • test - used to run tests

@JimLaskey
Copy link
Member Author

/help integrate

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

@JimLaskey Available commands:

  • cc - add or remove an additional classification label
  • clean - Mark the backport pull request as a clean backport
  • contributor - adds or removes additional contributors for a PR
  • covered - used when employer has signed the OCA
  • csr - require a compatibility and specification request (CSR) for this pull request
  • help - shows this text
  • integrate - performs integration of the changes in the PR
  • issue - edit the list of issues that this PR solves
  • label - add or remove an additional classification label
  • open - Set the pull request state to "open"
  • reviewer - manage additional reviewers for a PR
  • reviewers - set the number of additional required reviewers for this PR
  • signed - used after signing the OCA
  • solves - edit the list of issues that this PR solves
  • sponsor - performs integration of a PR that is authored by a non-committer
  • summary - updates the summary in the commit message
  • test - used to run tests

@JimLaskey
Copy link
Member Author

/issue remove JDK-8268770

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

@JimLaskey
Removing additional issue from issue list: 8268770.

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

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

8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes

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

  • 3bbd233: 8270075: SplittableRandom extends AbstractSplittableGenerator
  • 381bd62: 8266889: [macosx-aarch64] Crash with SIGBUS in MarkActivationClosure::do_code_blob during vmTestbase/nsk/jvmti/.../bi04t002 test run
  • 82c256e: 8259499: Handling type arguments from outer classes for inner class in javadoc
  • e5db9a9: 8268620: InfiniteLoopException test may fail on x86 platforms
  • 67273ae: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX
  • 0f54707: 8270056: Generated lambda class can not access protected static method of target class
  • 8583aab: 8270025: DynamicCallSiteDesc::withArgs doesn't throw NPE
  • d32e42c: 8270184: [TESTBUG] Add coverage for jvmci ResolvedJavaType.toJavaName() for lambdas
  • b2416b6: 8269281: java/foreign/Test{Down,Up}call.java time out
  • bd95c0c: 8269635: Stress test SEGV while emitting OldObjectSample
  • ... and 112 more: https://git.openjdk.java.net/jdk17/compare/b4743143428a3e0c9a6d1d7dcaf73f7a06882e84...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 Jul 14, 2021
@JimLaskey
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 14, 2021

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

  • 3bbd233: 8270075: SplittableRandom extends AbstractSplittableGenerator
  • 381bd62: 8266889: [macosx-aarch64] Crash with SIGBUS in MarkActivationClosure::do_code_blob during vmTestbase/nsk/jvmti/.../bi04t002 test run
  • 82c256e: 8259499: Handling type arguments from outer classes for inner class in javadoc
  • e5db9a9: 8268620: InfiniteLoopException test may fail on x86 platforms
  • 67273ae: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX
  • 0f54707: 8270056: Generated lambda class can not access protected static method of target class
  • 8583aab: 8270025: DynamicCallSiteDesc::withArgs doesn't throw NPE
  • d32e42c: 8270184: [TESTBUG] Add coverage for jvmci ResolvedJavaType.toJavaName() for lambdas
  • b2416b6: 8269281: java/foreign/Test{Down,Up}call.java time out
  • bd95c0c: 8269635: Stress test SEGV while emitting OldObjectSample
  • ... and 112 more: https://git.openjdk.java.net/jdk17/compare/b4743143428a3e0c9a6d1d7dcaf73f7a06882e84...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 14, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated labels Jul 14, 2021
@openjdk
Copy link

openjdk bot commented Jul 14, 2021

@JimLaskey Pushed as commit 72db09b.

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

@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core-libs core-libs-dev@openjdk.java.net integrated Pull request has been integrated
2 participants