-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Runtime uses jvm methods that are deprecated and may be soon removed #15387
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
This is tracked by #9013, as noted in that issue it doesn't seem possible to decide whether we can use VarHandle at runtime without ruining the performance of VarHandle |
What we could do is 1) under -release >= 9, use VarHandle properly 2) under -release 8, keep using unsafe but have a (potentially slower) runtime fallback if the method is not available |
Also I'm not sure if we already changed the default of -release to match the currently used jvm, I think we wanted to do that for 3.2 |
It looks like currently the default value is java 8 |
@smarter You want to have both (or even all three possible) implementations of lazy vals in the stdlib. Then, depending on the Am I getting it right? |
Two thoughts here :
|
@smarter That's fine (and also my expectation). I was focused primarily on the "default" JVM. |
The "default" is whatever is installed on your system, this is already the case now but it's not reflected in the class file version number we emit. |
If whining helps, it is annoying to go to try something out and it errors because my current jdk is 18. Perhaps if I read up on the linked ticket and the "new lazy val" PR, I'll understand the end game. |
I think it's important for the compiler to compile on every jdk people might use, so a PR that would silence the deprecation would be welcome. |
Just for silence #15520 |
Let's track this under #9013. |
Compiler version
At current main - 1ea177d, and also previous versions.
The problem
The problem is caused by usage of
Unsafe.objectFieldOffset
in runtime. When compiling the compiler on JVM 18, the following errors appear:It's not a problem per se, as we don't use this version of JDK on compiling. But, per the documentation:
And we heavily rely on this feature in the current and the new lazy vals implementation. It's not a problem now, but soon lazy vals can stop working on new jvms as we don't have any guarantee on their stability.
Proposal
Use MethodHandles to execute the Unsafe methods if the currently running jvm version == 1.8. In other case, use the VarHandles. It's a pretty complex approach and there may be another simpler solution.
The text was updated successfully, but these errors were encountered: