Open tb8367085 opened 1 year ago
Hessian 在 JDK 17 下兼容性不好
Fastjson2 的可以在 fastjson2 那边仓库提个 issue
2023-04-28T11:33:41.014+08:00 INFO 15224 --- [ncesChangeEvent] o.a.d.remoting.transport.AbstractClient : [DUBBO] Start NettyClient /192.168.2.35 connect to the server /192.168.2.35:20880, dubbo version: 3.2.0, current host: 192.168.2.35
java.lang.reflect.InaccessibleObjectException: Unable to make field final int java.math.BigInteger.signum accessible: module java.base does not "opens java.math" to unnamed module @7494f96a
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.getFieldMap(JavaDeserializer.java:340)
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.
@AlbumenJ
配置如下
dubbo.provider.prefer-serialization=fastjson2
依然报错
java.lang.reflect.InaccessibleObjectException: Unable to make field final int java.math.BigInteger.signum accessible: module java.base does not "opens java.math" to unnamed module @2e55dd0c
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.getFieldMap(JavaDeserializer.java:340)
at com.alibaba.com.caucho.hessian.io.JavaDeserializer.
启动增加如下参数,可以兼容,不报错了
--add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED
既然已经指定了序列化使用fastjson2,期望能去掉hessian的加载,这样就不用配置JVM参数了
Environment
Steps to reproduce this issue
配置文件:
Pls. provide [GitHub address] to reproduce this issue.
Expected Behavior
Actual Behavior
配置 dubbo.provider.prefer-serialization: hessian2 报反射相关私有属性问题
配置 dubbo.provider.prefer-serialization: fastjson2 报反射找不到 java.util.Collection$SynchronizedRandomAccessList的构造器,构造器jdk17+不是public的,所有报错,感觉是fastjson2 的问题
配置 dubbo.provider.prefer-serialization: java 后正常了