An illegal reflective access operation has occurred问题记录

报错

2023-11-30T01:08:18.744+0800 [ERROR] [system.err] WARNING: An illegal reflective access operation has occurred
2023-11-30T01:08:18.745+0800 [ERROR] [system.err] WARNING: Illegal reflective access by com.intellij.ui.JreHiDpiUtil to method sun.java2d.SunGraphicsEnvironment.isUIScaleEnabled()
2023-11-30T01:08:18.745+0800 [ERROR] [system.err] WARNING: Please consider reporting this to the maintainers of com.intellij.ui.JreHiDpiUtil
2023-11-30T01:08:18.745+0800 [ERROR] [system.err] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2023-11-30T01:08:18.745+0800 [ERROR] [system.err] WARNING: All illegal access operations will be denied in a future release
2023-11-30T01:08:19.394+0800 [ERROR] [system.err] 2023-11-30 01:08:19,393 [    795]   WARN - j.internal.DebugAttachDetector - Unable to start DebugAttachDetector, please add `--add-exports java.base/jdk.internal.vm=ALL-UNNAMED` to VM options 

环境

jdk azul-13.0.14
org.jetbrains.intellij 1.5.2
gradle 7.4.2

解决

Illegal reflective access by com.intellij.ui.JreHiDpiUtil to method sun.java2d.SunGraphicsEnvironment.isUIScaleEnabled()
意思是在JreHiDpiUtil 类中非法使用了反射访问SunGraphicsEnvironment.isUIScaleEnabled()方法

类似的还有
Illegal reflective access by com.intellij.ide.ui.laf.darcula.DarculaLaf to field javax.swing.text.html.HTMLEditorKit.DEFAULT_STYLES_KEY

要么更换包要么只能接收这个警告

可以使用jvm参数查看更加详细的信息
--illegal-access=debug --add-opens java.base/java.lang=ALL-UNNAMED
如果不想所有的配置都添加这个参数可以在自定义vm惨出生中添加
An illegal reflective access operation has occurred问题记录_第1张图片

其实这是 JDK9 中添加的新特性,即 reflect 不再可以访问 non-public 成员以及不可公开访问的 class,原先这些访问控制虽然存在但是可以通过 reflect 绕过,从 JDK9 开始反射也将遵循访问控制的规则。JDK9 中对于第一次访问非公开成员的操作会显示警告信息,我们可以通过使用–illegal-access=warn选项进一步显示出有用的 warning 提示

参考链接

你可能感兴趣的:(gradle&idea,gradle,ideal,plugin)