关于 com.fasterxml.jackson.databind.util.ClassUtil 非法反射访问的警告
我在运行我的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论