Skip to content
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

jdk16环境下example报错 #633

Closed
tsgmq opened this issue Jul 5, 2021 · 14 comments · Fixed by #636
Closed

jdk16环境下example报错 #633

tsgmq opened this issue Jul 5, 2021 · 14 comments · Fixed by #636

Comments

@tsgmq
Copy link

tsgmq commented Jul 5, 2021

com.alipay.sofa.jraft.storage.log.SegmentFile 编译不通过
报错信息
java: 程序包 sun.nio.ch 不可见
(程序包 sun.nio.ch 已在模块 java.base 中声明, 但该模块未将它导出到未命名模块)
image

@killme2008
Copy link
Contributor

应该是误用了,我们改下,您要有兴趣也可以提个修复 PR

@fengjiachun
Copy link
Contributor

这个不是误用,只有 sun.nio.ch.DirectBuffer 有 address() api, DirectByteBuffer 只是包可见级别,外部无法访问

@killme2008
Copy link
Contributor

我的意思是可以改成反射的方式,不需要强依赖。

@tsgmq
Copy link
Author

tsgmq commented Jul 5, 2021

我的水平太菜了,不会改,麻烦修改下,我重新下载代码

@tsgmq
Copy link
Author

tsgmq commented Jul 5, 2021

Method method = this.buffer.getClass().getMethod("address");
final long address = (long)method.invoke(this.buffer);

@fengjiachun
Copy link
Contributor

我下载个 zulu jdk16 看下怎么改好些

@fengjiachun
Copy link
Contributor

我下载了 jdk16, 发现可以编译,你的报错是你的 idea 报错吧?

@fengjiachun
Copy link
Contributor

本地执行一下 mvn clean compile 看看?如果可以编译,那么可能需要看看怎么修改一下你的 IDE 的配置

@closess
Copy link

closess commented Jul 6, 2021

跟你一样的问题,我用的jdk11,哈哈哈
解决方式:鼠标点击那个报红的区域,然后直接使用’ALT + Enter‘自动修复一下就可以了

@tsgmq
Copy link
Author

tsgmq commented Jul 7, 2021

java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.StackTraceElement.classLoaderName accessible: module java.base does not “opens java.lang” to unnamed module @5cbc508c
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
at com.caucho.hessian.io.JavaDeserializer.getFieldMap(JavaDeserializer.java:329)
at com.caucho.hessian.io.JavaDeserializer.(JavaDeserializer.java:97)
at com.caucho.hessian.io.StackTraceElementDeserializer.(StackTraceElementDeserializer.java:57)
at com.caucho.hessian.io.SerializerFactory.(SerializerFactory.java:589)
at com.alipay.remoting.serialization.HessianSerializer.(HessianSerializer.java:36)
at com.alipay.remoting.serialization.SerializerManager.(SerializerManager.java:36)
at com.**.CommandCodec.decodeCommand(CommandCodec.java:34)
at com.jraft.snapshot.TradeSnapshotFile.load(TradeSnapshotFile.java:50)
at com.
.jraft.statemachine.ArcTradingDraftPkgStateMachine.onSnapshotLoad(ArcTradingDraftPkgStateMachine.java:280)
at com.alipay.sofa.jraft.core.FSMCallerImpl.doSnapshotLoad(FSMCallerImpl.java:652)
at com.alipay.sofa.jraft.core.FSMCallerImpl.runApplyTask(FSMCallerImpl.java:398)
at com.alipay.sofa.jraft.core.FSMCallerImpl.access$100(FSMCallerImpl.java:73)
at com.alipay.sofa.jraft.core.FSMCallerImpl$ApplyTaskHandler.onEvent(FSMCallerImpl.java:148)
at com.alipay.sofa.jraft.core.FSMCallerImpl$ApplyTaskHandler.onEvent(FSMCallerImpl.java:142)
at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:137)
at java.base/java.lang.Thread.run(Thread.java:831)

@tsgmq
Copy link
Author

tsgmq commented Jul 7, 2021

    <jraft-core-version>1.3.7</jraft-core-version>

@killme2008
Copy link
Contributor

@tsgmq 这个是你自己实现的吧 TradeSnapshotFile ,不是 jraft 的问题。

@closess
Copy link

closess commented Jul 8, 2021

我的jdk11也不能用。
这种方式应该是只有jdk8可以用,jdk8以上就不能用了。
你可以照我上面的方式修复一下就行了

@tsgmq
Copy link
Author

tsgmq commented Jul 8, 2021

感谢各位指点,主要是SerializerManager.getSerializer(SerializerManager.Hessian2).deserialize(content, clazz.getName()) 这个序列化的不行,本地解决了在服务器jdk16依然不行,我已经换成ProtoStuffSerializer来做序列化和反序列化,通过其他方式解决

@tsgmq tsgmq closed this as completed Jul 8, 2021
fengjiachun pushed a commit that referenced this issue Jul 9, 2021
* (fix) sun.nio.ch.DirectBuffer compile error in latest jdk, #633
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 a pull request may close this issue.

4 participants