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

8315938: Deprecate for removal Unsafe methods that have standard APIs for many releases #15641

Closed
wants to merge 1 commit into from

Conversation

AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Sep 8, 2023

There are several methods defined by sun.misc.Unsafe that have standard API equivalents for many years and releases. The change proposed here is to deprecate, for removal, the park, unpark, getLoadAverage, loadFence, storeFence, and fullFence methods. Code using these methods should move to LockSupport.park/unpark (Java 5), OperatingSystemMXBean.getSystemLoadAverage (Java 6), and VarHandles xxxFence methods (Java 9).

The following is a summary of a search of 175973022 classes in 484751 artifacts to get a sense of the usage of these methods.

  • 1290 usages of Unsafe.park. 1195 are libraries that have re-packaged some version of ForkJoinPool, maybe from the jsr166 repo, maybe an older JDK release. In the remaining, only Ehcache stands out with 29 matches. It seems to be one usage but the library seems to copied/shaded into other artifacts.

  • 1322 usages of Unsafe.unpark. 1243 are re-packaged ForkJoinPool. 29 occurrences are Encache, again one usage but the library seems to copied/shaded into other artifacts.

  • 22 usages of Unsafe.getLoadAverage. Most of these are one usage in many published versions of Apache HBase.

  • 339 usages of Unsafe.loadFence, 1057 usages of Unsafe.storeFence, 517 usages of Unsafe.fullFence. A handful of these are libraries with copies of j.u.concurrent, the rest seem to be high performance libraries that support older JDK releases or just haven't been updated to use VarHandles yet.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8315953 to be approved
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8315938: Deprecate for removal Unsafe methods that have standard APIs for many releases (Enhancement - P4)
  • JDK-8315953: Deprecate for removal Unsafe methods that have standard APIs for many releases (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15641

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

Using diff file

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

Webrev

Link to Webrev Comment

@AlanBateman
Copy link
Contributor Author

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 8, 2023

👋 Welcome back alanb! 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 csr Pull request needs approved CSR before integration label Sep 8, 2023
@openjdk
Copy link

openjdk bot commented Sep 8, 2023

@AlanBateman has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@AlanBateman please create a CSR request for issue JDK-8315938 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Sep 8, 2023

@AlanBateman 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 8, 2023
@AlanBateman AlanBateman marked this pull request as ready for review September 8, 2023 18:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 8, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 8, 2023

Webrevs

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

A good set of Unsafe APIs for terminal deprecation and the API replacements exist for some time.

Copy link
Member

@irisclark irisclark left a comment

Choose a reason for hiding this comment

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

Happy to see these methods start their journey towards eventual removal.

@minborg
Copy link
Contributor

minborg commented Sep 11, 2023

Currently, all deprecated methods of Unsafe are at the end of the file. Is there a specific reason for this other than that they are deprecated? Would it make sense to move down the newly deprecated methods to the end of the file?

@AlanBateman
Copy link
Contributor Author

Currently, all deprecated methods of Unsafe are at the end of the file.

Are you looking at the internal Unsafe, rather than sun.misc.Unsafe? This PR is sun.misc.Unsafe only. Previous deprecation didn't re-order the methods. With VarHandles in 9, and FFM highly likely to become permanent in 22, then we'll probably see a lot more deprecation, degrading and removing of methods. It would be noisy to reshuffle at every step.

@openjdk
Copy link

openjdk bot commented Sep 11, 2023

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

8315938: Deprecate for removal Unsafe methods that have standard APIs for many releases

Reviewed-by: mchung, psandoz, iris

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

  • d0be73a: 8041488: Locale-Dependent List Patterns
  • dd214d0: 8315437: Enable parallelism in vmTestbase/nsk/monitoring/stress/classload tests
  • 877731d: 8315770: serviceability/sa/TestJmapCoreMetaspace.java should run with -XX:-VerifyDependencies
  • d06a564: 8315765: G1: Incorrect use of G1LastPLABAverageOccupancy
  • 66b6a5a: 8277954: Replace use of monitors with explicit locks in the JDK LDAP provider implementation
  • 4cb4637: 8315970: Big-endian issues after JDK-8310929
  • ae08143: 8315611: Open source swing text/html and tree test
  • 7b3e697: 8315855: G1: Revise signature of set_humongous_candidate
  • 1941290: 8315942: Sort platform enums and definitions after JDK-8304913 follow-ups
  • 996b336: 8315781: Reduce the max value of GCDrainStackTargetSize
  • ... and 11 more: https://git.openjdk.org/jdk/compare/e409d07ae84c693b656c02befb636593f9293635...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 ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Sep 11, 2023
@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 12, 2023

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

  • fda142f: 8312174: missing JVMTI events from vthreads parked during JVMTI attach
  • d0be73a: 8041488: Locale-Dependent List Patterns
  • dd214d0: 8315437: Enable parallelism in vmTestbase/nsk/monitoring/stress/classload tests
  • 877731d: 8315770: serviceability/sa/TestJmapCoreMetaspace.java should run with -XX:-VerifyDependencies
  • d06a564: 8315765: G1: Incorrect use of G1LastPLABAverageOccupancy
  • 66b6a5a: 8277954: Replace use of monitors with explicit locks in the JDK LDAP provider implementation
  • 4cb4637: 8315970: Big-endian issues after JDK-8310929
  • ae08143: 8315611: Open source swing text/html and tree test
  • 7b3e697: 8315855: G1: Revise signature of set_humongous_candidate
  • 1941290: 8315942: Sort platform enums and definitions after JDK-8304913 follow-ups
  • ... and 12 more: https://git.openjdk.org/jdk/compare/e409d07ae84c693b656c02befb636593f9293635...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 12, 2023

@AlanBateman Pushed as commit d08258f.

💡 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
5 participants