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

[FEATURE] JSONObject.to 方法在高版本jdk中对Void类型的支持问题 #2879

Closed
wpinchine opened this issue Aug 20, 2024 · 1 comment
Closed
Labels
bug Something isn't working enhancement New feature or request fixed
Milestone

Comments

@wpinchine
Copy link

wpinchine commented Aug 20, 2024

请描述您的需求或者改进建议

对您想要需求或建议的清晰简洁的描述。

在jdk8中,以下代码是能够正常运行的
JSON.parseObject(jsonString).to(Void.class);
但是在jdk21中,会报以下错误:java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Void() accessible: module java.base does not "opens java.lang" to unnamed module @7ce026d3
需要在启动参数中加入:--add-opens java.base/java.lang=ALL-UNNAMED 才可以正常运行

请描述你建议的实现方案

对您想要需求或建议的实现方案的详细描述。

针对此问题,建议JSONObject.to针对Void.class直接返回null

描述您考虑过的替代方案

对您考虑过的任何替代解决方案或功能的描述。

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@wpinchine wpinchine added the enhancement New feature or request label Aug 20, 2024
@wpinchine wpinchine changed the title [FEATURE] JSONObject.to 方法对在高版本jdk中对Void类型的支持有问题 [FEATURE] JSONObject.to 方法在高版本jdk中对Void类型的支持问题 Aug 20, 2024
@wenshao wenshao added this to the 2.0.53 milestone Aug 20, 2024
@wenshao wenshao added the bug Something isn't working label Aug 20, 2024
@wenshao wenshao modified the milestones: 2.0.53, 2.0.54 Sep 16, 2024
@wenshao wenshao added the fixed label Jan 1, 2025
@wenshao
Copy link
Member

wenshao commented Jan 12, 2025

@wenshao wenshao closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

2 participants