【发布时间】:2020-12-04 23:52:27
【问题描述】:
我在使用 java 11 在 Tomcat 9 服务器上运行我的 webapp 时收到一条警告消息。
错误如下:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$2 (file:/C:/Users/<myuser>/Documents/Workspace2019-09/.metadata/.plugins/org.eclipse.wst.server.core/tmp8/wtpwebapps/myproject/WEB-INF/lib/guice-3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
我用谷歌搜索了这个特定的错误,发现将以下内容添加到 VM 参数将解决警告。
--add-opens java.base/java.lang=ALL-UNNAMED
是否有解决此类错误的替代方法?有人建议使用以下方法对其进行调试。谁负责维护 com.google.inject.internal.cglib.core? guice 3.0 多久不支持?
--illegal-access=deny
警告本身说要使用以下内容:
--illegal-access=warn
【问题讨论】:
-
我强烈建议使用更新的版本 google guice search.maven.org/artifact/com.google.inject/guice 您使用的版本是 9 岁。