异常信息
Caused by: java.lang.reflect.InaccessibleObjectException:
Unable to make protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible:
module java. base does not "opens java. lang" to unnamed module @661972b0
————————————————
jdk1.8正常运行,而高版本jdk17运行报错
java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.util.HashMap$Node[] java.util.HashMap.table accessible: module java.base does not “opens java.util” to unnamed module @200a570f,
解决方法:(针对于Idea2023.3版本)
Run—>EditConfigurations…—>Modify options—>Add VM options—>JVM options
在JVM options 内添加下面指令:
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED