-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8277863: Deprecate sun.misc.Unsafe methods that return offsets #6700
Conversation
👋 Welcome back alanb! A progress list of the required criteria for merging this PR into |
@AlanBateman The following label will be automatically applied to this pull request:
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. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slowly chipping away... but we are getting really close to being able to deprecate all the unsafe accessor methods.
Did you also consider the method staticFieldBase
and the field INVALID_FIELD_OFFSET
? I think those could also be included since the aim is to discourage unsafe access to fields of objects.
Yes, we have to keep chipping away at this. Most of the on-heap usages that I found could have been replaced with VarHandles a long time ago but many of these projects are still building to old JDK releases and maybe MR JARs are still problematic in the build. The great progress on the memory API in Project Panama means it won't be long before those accessors are needed for off-heap. So yes, a few more releases and we should be able to make more progress. I toyed with including staticFieldBase but I didn't find anything like the usage as the offset methods. Easy to include if you think it's worth doing. |
Yes, I think you should include it, it's part of this set of functionality (since base is used in conjunction with offsets) |
Okay, done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay to leave INVALID_FIELD_OFFSET
as is as it's also for arrayBaseOffset
.
/integrate |
@AlanBateman This pull request has not yet been marked as ready for integration. |
@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:
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 9 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit 56ca66e.
Your commit was automatically rebased without conflicts. |
@AlanBateman Pushed as commit 56ca66e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Deprecate the sun.misc.Unsafe methods that return field offsets. These method are an impediment to possible future changes. Layout may not be fixed in the future, the VM should be allowed to re-layout dynamically based on patterns of usage. We also have the issue of libraries using these methods to get offsets (sometimes of classes with the same layout as JDK classes) so they can directly access the fields of privileged classes. It's untenable for libraries to rely on this going forward.
The java.lang.invoke.VarHandle API (added in Java 9) provides a strongly typed reference to a variable that is a safe and a much better alternative to many cases that use these methods. Deprecating these method provides a gentle nudge in that directory. Once the Panama memory APIs are permanent then we can look at terminally deprecating and removing these methods, along with the accessors.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6700/head:pull/6700
$ git checkout pull/6700
Update a local copy of the PR:
$ git checkout pull/6700
$ git pull https://git.openjdk.java.net/jdk pull/6700/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6700
View PR using the GUI difftool:
$ git pr show -t 6700
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6700.diff