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

8265137: java.util.Random suddenly has new public methods nowhere documented #3469

Closed
wants to merge 10 commits into from

Conversation

JimLaskey
Copy link
Member

@JimLaskey JimLaskey commented Apr 13, 2021

Move makeXXXSpilterator from public (@hidden) to protected. No API ch


Progress

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

Issue

  • JDK-8265137: java.util.Random suddenly has new public methods nowhere documented

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3469

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

Using diff file

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

@JimLaskey
Copy link
Member Author

/label core-libs

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 13, 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 rfr Pull request is ready for review core-libs core-libs-dev@openjdk.org labels Apr 13, 2021
@openjdk
Copy link

openjdk bot commented Apr 13, 2021

@JimLaskey
The core-libs label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Apr 13, 2021

Copy link
Member

@uschindler uschindler 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 exactly like my proposed solution!

+1 Thanks!

@uschindler
Copy link
Member

Just my question: Is @hidden not needed to remove the documentation from protected method? Or is this automatically hidden by javadoc?

@JimLaskey
Copy link
Member Author

Just my question: Is @hidden not needed to remove the documentation from protected method? Or is this automatically hidden by javadoc?

protected methods don't show up.

@AlanBateman
Copy link
Contributor

/csr

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

openjdk bot commented Apr 14, 2021

@AlanBateman has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@JimLaskey please create a CSR request and add link to it in JDK-8265137. This pull request cannot be integrated until the CSR request is approved.

Copy link
Member

@uschindler uschindler left a comment

Choose a reason for hiding this comment

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

To me this looks fine. It is all a bit of hack, but this makes sure the public API of java.util.Random does not change in comparison to JDK 16.
The final protected method may be visible by IDEs but it cannot be called und is not overrideable as it is final.

@forax
Copy link
Member

forax commented Apr 14, 2021

I don't see the point of having those methods virtual, they can be public static in RandomSupport given that there is only one implementation (the one with an if ... instanceof).
Also the static final proxy should be spelled PROXY.

@uschindler
Copy link
Member

Due to the changes now: I think the CSR got obsolete?

@JimLaskey
Copy link
Member Author

I put the CSR back to draft until I was happy with the changeset.

@JimLaskey
Copy link
Member Author

/help

@openjdk
Copy link

openjdk bot commented Apr 22, 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 reviewer

@openjdk
Copy link

openjdk bot commented Apr 22, 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

@forax
Copy link
Member

forax commented Apr 22, 2021

Looks good

+1

Copy link
Member

@stuart-marks stuart-marks left a comment

Choose a reason for hiding this comment

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

Overall looks good.

AbstractSpliteratorGenerator now is a bit weird because it's a utility class that has static methods, and it's an abstract superclass that has instance methods that mostly just call the static methods. Seems to me that additional cleanup is possible. It might not be worth it right now, since the main point of this PR -- to remove "leakage" of these helper methods into the public API -- has been achieved.

The RandomXXXSpliterator nested classes could also stand some scrutiny. The constructors consume a RandomGenerator, which is stored in an instance variable. Various comments still refer to this as an AbstractSpliteratorGenerator. (See line 961 for example; can't comment directly because it's not part of this commit.)

But it's not clear to me that the RandomXXXSpliterator classes really need a full RandomGenerator. For example, as far as I can see, RandomIntSpliterator only needs nextInt to generate int values; therefore it could be IntSupplier. Similar for long and double. (I'm applying the Interface Segregation Principle here.) But again this is probably a cleanup for another day.

*/
protected AbstractSpliteratorGenerator() {
private AbstractSpliteratorGenerator() {
}

Copy link
Member

Choose a reason for hiding this comment

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

This comment is wrong now since there are instances of this class (really, subclasses). The constructor should probably simply be removed.

Copy link
Member

@uschindler uschindler left a comment

Choose a reason for hiding this comment

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

Hi,
the overall setup is mch better than before! This also makes the problem we have seen in policeman-tools/forbidden-apis#177 go away, because Random/ThreadLocalRandom no longer extend a public, but internal/hidden class (forbiddenapis is a classfile analyzer that tries to prevent user's from extending internal JDK APIs in one of its checks). When looking into superclasses of Random, it detected a "bad superclass from an internal package".

So this alone makes me very happy with this.

In addition, it no longer changes APIs of Random/ThreadLocalRandom, only the new interface is added.

+1 to merge

@JimLaskey
Copy link
Member Author

Please mark the CSR https://bugs.openjdk.java.net/browse/JDK-8265221 as reviewed.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label May 4, 2021
@openjdk
Copy link

openjdk bot commented May 4, 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:

8265137: java.util.Random suddenly has new public methods nowhere documented

Reviewed-by: uschindler, darcy, 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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 May 4, 2021
@JimLaskey
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this May 4, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 4, 2021
@openjdk
Copy link

openjdk bot commented May 4, 2021

@JimLaskey Pushed as commit 05e6017.

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

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
6 participants