Skip to content

ByteBufferCleaner to check Unsafe access in Java 23+#866

Draft
maxxedev wants to merge 5 commits into
apache:masterfrom
maxxedev:master
Draft

ByteBufferCleaner to check Unsafe access in Java 23+#866
maxxedev wants to merge 5 commits into
apache:masterfrom
maxxedev:master

Conversation

@maxxedev

Copy link
Copy Markdown
Contributor

In Java 23+, ByteBufferCleaner should check for access to deprecated memory-access methods in sun.misc.Unsafe

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • [] I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? Not used
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

In Java 23+, ByteBufferCleaner should check for access
to deprecated memory-access methods in sun.misc.Unsafe
@garydgregory
garydgregory marked this pull request as draft July 19, 2026 08:33
@garydgregory

Copy link
Copy Markdown
Member

Converting to draft until I can have a closer look, needs clean ups anyway.

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are several problems here:

  • The build fails
  • Using java.lang.management adds a new module dependency which some people will complain about. We could disallow this through Checkstyle but we currently do not.
  • It's not clear to me this is the correct implementation since the JEP is just a deprecation.
  • There is a bug where clearWritable() is not called.

@maxxedev

Copy link
Copy Markdown
Contributor Author

build fails

fixed

* Using `java.lang.management` adds a new module dependency which some people will complain about. We could disallow this through Checkstyle but we currently do not.

we just disable Unsafe access on Java 23+ now

* It's not clear to me this is the correct implementation since the JEP is just a deprecation.

deprecation is for removal. Plus, most users would want the library to not trigger scary warnings.

* There is a bug where `clearWritable()` is not called.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants