Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Sign in
sdk-java
sdk-java
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

  • chainmaker
  • sdk-javasdk-java
  • Issues
  • #22

Closed (moved)
Open
Opened Jul 25, 2025 by Jean Li Zhen@jean-lizhen

在java 21版本中运行chainMaker sdk异常

基于openjdk 21版本运行,配套2.3.3版本SDK+Spring boot启动app过程异常如下(netty-handler版本4.1.53)

11:09:26.036 [main] ERROR o.c.s.c.ChainmakerX509CryptoSuite - [<clinit>,75] - CurveDB enableGM err :
java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field[] java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not "opens java.lang" to unnamed module @2d2ffcb7
        at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203)
        at java.base/java.lang.reflect.Method.setAccessible(Method.java:197)
        at org.chainmaker.sdk.crypto.ChainmakerX509CryptoSuite.loadAlgorithms(ChainmakerX509CryptoSuite.java:445)
        at org.chainmaker.sdk.crypto.ChainmakerX509CryptoSuite.<clinit>(ChainmakerX509CryptoSuite.java:72)
        at org.chainmaker.sdk.User.<init>(User.java:84)

在jvm启动参数增加--add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED后这个异常处理掉了,但是还有新的异常:

Caused by: java.lang.InternalError: java.lang.IllegalAccessException: static final field has no write access: io.netty.handler.ssl.ExtendedOpenSslSession.LOCAL_SUPPORTED_SIGNATURE_ALGORITHMS/[Ljava.lang.String;/putStatic, from class java.lang.Object (module java.base)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newFieldAccessor(MethodHandleAccessorFactory.java:167)
	at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:145)
	at java.base/java.lang.reflect.Field.acquireOverrideFieldAccessor(Field.java:1200)
	at java.base/java.lang.reflect.Field.getOverrideFieldAccessor(Field.java:1169)
	at java.base/java.lang.reflect.Field.get(Field.java:444)
	at org.chainmaker.sdk.crypto.ChainmakerX509CryptoSuite.loadAlgorithms(ChainmakerX509CryptoSuite.java:458)
	at org.chainmaker.sdk.crypto.ChainmakerX509CryptoSuite.<clinit>(ChainmakerX509CryptoSuite.java:72)

通过阅读代码,发现应该是想要加载国密算法到netty,通过咨询大模型给出的建议,如果要扩展netty的ssl算法,通过SslContextBuilder+SslHandler来实现,不要违法final static的安全原则去修改他。

Edited Jul 25, 2025 by Jean Li Zhen
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: chainmaker/sdk-java#22

Copyright © 2021 ChainMaker Org. All Rights Reserved. 长安链 版权所有。