org.springframework.cglib.core.ReflectUtils$1 的非法反射访问 [英] Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1
问题描述
我的 JDK 9+181 Spring Boot 2.0.0.BUILD-SNAPSHOT CLI 应用程序在启动时显示此警告:
My JDK 9+181 Spring Boot 2.0.0.BUILD-SNAPSHOT CLI application displays this warning on startup:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/home/jan/src/fm-cli/target/fm-cli-0.1.0-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-5.0.0.RELEASE.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 org.springframework.cglib.core.ReflectUtils$1
这是一个控制台应用程序,所以我需要禁用这个警告——我该怎么做?
This is a console application, so I need to disable this warning -- how can I do that?
注:本题询问具体的问题是如何禁用Spring触发的这个警告;它不是 JDK9 的副本:发生了非法的反射访问操作.org.python.core.PySystemState 处理不同库中的类似症状.
Note: This question asks the specific question of how to disable this warning triggered by Spring; it is not a duplicate of JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState which deals with a similar symptom in a different library.
推荐答案
在 JDK 9+ 中,向 JVM 添加以下选项以禁用 Spring 使用 CGLIB 的警告:
In JDK 9+, add the following option to the JVM to disable the warning from Spring's use of CGLIB:
--add-opens java.base/java.lang=ALL-UNNAMED
例如:
java --add-opens java.base/java.lang=ALL-UNNAMED -jar target/*.jar
无需报告;这是一个 已知的 Spring 错误.
No need to report it; it's a known Spring bug.
发生这种情况是因为新的 JDK 9 模块系统检测到在(不久的)将来某个时候将被禁止的非法访问.您可以阅读更多关于 JDK 9 模块系统在这里.
This happens because the new JDK 9 module system detected an illegal access that will be disallowed sometime in the (near) future. You can read more about the JDK 9 Module system here.
更新:
JDK 9+ 和 Spring 5.1+ 提供了针对此问题的修复.
A fix for this issue is available JDK 9+ with Spring 5.1+.
这篇关于org.springframework.cglib.core.ReflectUtils$1 的非法反射访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!