-
Notifications
You must be signed in to change notification settings - Fork 78
Replace deprecated Unsafe API #165
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
Comments
Thanks for the issue! Yes, we know we should move to Java 9 VarHandle, but since this library still supports 8 we need to be able to work both ways. Perhaps you can help with a VarHandle patch? |
@headius Thanks for the very fast feedback. If you want support the out dated Java 8 in the future then a possible solution for Java 8 support and the use of VarHandle in newer Java versions can be a multi-release jar file.
No, I have self never use Unsafe or VarHandle. I know that it exists. This is all. This is not a good base to write a patch. |
Warnings show up for JRuby users so we'll need a fix sooner than later: jruby/jruby#8696 |
I started looking into the code and it's not actually something we can use VarHandle for. The code in question is actually for doing IO to and from native memory given a pointer value. We will need to replace it with Project Panama's foreign memory API conditionally. We do, however, do have a property to disable Unsafe use at least for this case: |
A second option is this JVM flag you can use to disable the warning: We are debating whether we fix this or just push forward with the FFM-based jnr-ffi in https://github.com/JornVernee/jnr-ffi/tree/panama-22-unsquashed. |
I get the follow on the console with Java 23:
If I look into the source of Unsafe you should use the class VarHandle which exists since Java 9.
The text was updated successfully, but these errors were encountered: