关于 com.fasterxml.jackson.databind.util.ClassUtil 非法反射访问的警告

发布于 2025-01-14 02:35:17 字数 1282 浏览 2 评论 0原文

我在运行我的java应用程序时间歇性地收到以下警告,

WARNING: All illegal access operations will be denied in a future release
WARNING: An illegal reflective access operation has occurred
WARNING: Please consider reporting this to the maintainers of 
com.fasterxml.jackson.databind.util.ClassUtil
WARNING: Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil 
(file:/usr/app/my_app.jar) to field java.lang.Throwable.cause

我认为下面的行可能与此有关,

private final static ObjectMapper mapper = new ObjectMapper();
AuthInfo authInfo = mapper.readValue(userInfo, AuthInfo.class);

但是即使我尝试使用与生产相同的输入,我也无法在本地重现此问题。我已经使用 --add-opens 来忽略这些警告,它的工作原理,但我想知道为什么会发生这种情况以及如何修复反射访问警告。

尝试使用 –-illegal-access=debug 来获取堆栈跟踪,但我得到 使用:

java –-illegal-access=debug -jar my_application.jar

出现错误,例如,

Error: Could not find or load main class –-illegal-access=debug
Caused by: java.lang.ClassNotFoundException: –-illegal-access=debug

我正在使用 Java 11.0.2

编辑: 我还收到以下警告,

WARNING: Illegal reflective access by com.amazonaws.util.XpathUtils (file:/usr/app/m1x-publish.jar) to method com.sun.org.apache.xpath.internal.XPathContext.getDTMManager()

I am getting the below warning intermittently while running my java application,

WARNING: All illegal access operations will be denied in a future release
WARNING: An illegal reflective access operation has occurred
WARNING: Please consider reporting this to the maintainers of 
com.fasterxml.jackson.databind.util.ClassUtil
WARNING: Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil 
(file:/usr/app/my_app.jar) to field java.lang.Throwable.cause

I think the below line may have connection with this,

private final static ObjectMapper mapper = new ObjectMapper();
AuthInfo authInfo = mapper.readValue(userInfo, AuthInfo.class);

However I am unable to reproduce this issue in my local even if I try with the same input that production has. I have used --add-opens to ignore these warnings, its working but I want to know why this is happening and how to fix that reflection access warnings.

Tried to use –-illegal-access=debug to get the stack trace but I am getting
Used:

java –-illegal-access=debug -jar my_application.jar

Getting error like,

Error: Could not find or load main class –-illegal-access=debug
Caused by: java.lang.ClassNotFoundException: –-illegal-access=debug

I am using Java 11.0.2

Edit:
I am also getting the below warning,

WARNING: Illegal reflective access by com.amazonaws.util.XpathUtils (file:/usr/app/m1x-publish.jar) to method com.sun.org.apache.xpath.internal.XPathContext.getDTMManager()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文