sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.52k stars 1.12k forks source link

Is there a plan to support higher versions of JDK, such as JDK 17? #1070

Open TaXueWWL opened 5 months ago

TaXueWWL commented 5 months ago

Your question

Is there a plan to support higher versions of JDK, such as JDK 17?

Your scenes

we have already upgrade to jdk17

Your advice

when compile with jdk17, occur error: ...\sofa-jraft\jraft-core\src\main\java\com\alipay\sofa\jraft\util\internal\UnsafeIntegerFieldUpdater.java:20:16 java: 程序包sun.misc不存在

Environment

fengjiachun commented 5 months ago

It's a good suggestion, I will try to support JDK17 in the next version, but I don't know how much work it will involve yet. The next version may not be released quickly, maybe in 2 months. Of course, if you are interested in sending a PR for this, you are very welcome to do so.

TaXueWWL commented 5 months ago

I found a temporary way to solve the compile problem. Add: --add-modules=jdk.unsupported when compile and Add:
--add-modules=jdk.unsupported --add-opens=java.base/sun.nio.ch=ALL-UNNAMED when run the app.

zxuanhong commented 4 months ago

@TaXueWWL @fengjiachun 我试着用jdk17,发现会导致rpc提示(注意是:CliService操作集群时,但是启动正常):Connection is null when do check!。实际不是网络问题,我降低到1.8就正常了。我感觉还是有很大问题

fengjiachun commented 4 months ago

@TaXueWWL @fengjiachun 我试着用jdk17,发现会导致rpc提示(注意是:CliService操作集群时,但是启动正常):Connection is null when do check!。实际不是网络问题,我降低到1.8就正常了。我感觉还是有很大问题

For more detail: #1083

syhily commented 1 month ago

After testing the sofa-jraft locally, I met some issues in using JDK 17, such as the sun.misc issue. Given that sofa-jraft didn't fully support the JDK 17, I don't know why we close this issue without any clarification.

fengjiachun commented 1 month ago

After testing the sofa-jraft locally, I met some issues in using JDK 17, such as the sun.misc issue. Given that sofa-jraft didn't fully support the JDK 17, I don't know why we close this issue without any clarification.

Sorry, I made a mistake. I thought the author of #1083 had already found a solution. I will reopen this issue.

syhily commented 1 month ago

Thanks for reopening this issue. The main issue in using sofa-jraft with higher JDK is that the difference of OpenJDK and Oracle JDK and the Unsafe has been move to jdk.internal.misc module. This may require the code refactoring in dropping the Unsafe usage. I may try to find a better solution on this.