Java报错处理系列之:Unable to make protected void java.util.ResourceBundle.setParent

Java报错处理系列之:Internal error : Unable to make protected void java.util.ResourceBundle.setParent accessible: module java.base does not "opens java.util" to unnamed module @7f1302d6

一、完整报错

执行Java代码出现以下报错:

  • Internal error (java.lang.reflect.InaccessibleObjectException): Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @7f1302d6
    java.lang.reflect.InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @7f1302d6
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:201)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:195)
    at com.intellij.util.ReflectionUtil.makeAccessible(ReflectionUtil.java:253)
    at com.intellij.util.ReflectionUtil.getDeclaredMethod(ReflectionUtil.java:270)
    at com.intellij.DynamicBundle.(DynamicBundle.java:28)
    at org.jetbrains.jps.incremental.scala.InitialScalaBuilder.getPresentableName(InitialScalaBuilder.scala:26)
    at org.jetbrains.jps.incremental.IncProjectBuilder.lambda$sendElapsedTimeMessages$3(IncProjectBuilder.java:451)
    at java.base/java.util.stream.ReferencePipeline3 1. a c c e p t ( R e f e r e n c e P i p e l i n e . j a v a : 197 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . C o n c u r r e n t H a s h M a p 1.accept(ReferencePipeline.java:197) at java.base/java.util.concurrent.ConcurrentHashMap 1.accept(ReferencePipeline.java:197)atjava.base/java.util.concurrent.ConcurrentHashMapEntrySpliterator.forEachRemaining(ConcurrentHashMap.java:3652) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps F o r E a c h O p . e v a l u a t e S e q u e n t i a l ( F o r E a c h O p s . j a v a : 150 ) a t j a v a . b a s e / j a v a . u t i l . s t r e a m . F o r E a c h O p s ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps ForEachOp.evaluateSequential(ForEachOps.java:150)atjava.base/java.util.stream.ForEachOpsForEachOp O f R e f . e v a l u a t e S e q u e n t i a l ( F o r E a c h O p s . j a v a : 173 ) a t j a v a . b a s e / j a v a . u t i l . s t r e a m . A b s t r a c t P i p e l i n e . e v a l u a t e ( A b s t r a c t P i p e l i n e . j a v a : 234 ) a t j a v a . b a s e / j a v a . u t i l . s t r e a m . R e f e r e n c e P i p e l i n e . f o r E a c h ( R e f e r e n c e P i p e l i n e . j a v a : 596 ) a t o r g . j e t b r a i n s . j p s . i n c r e m e n t a l . I n c P r o j e c t B u i l d e r . s e n d E l a p s e d T i m e M e s s a g e s ( I n c P r o j e c t B u i l d e r . j a v a : 454 ) a t o r g . j e t b r a i n s . j p s . i n c r e m e n t a l . I n c P r o j e c t B u i l d e r . r u n B u i l d ( I n c P r o j e c t B u i l d e r . j a v a : 425 ) a t o r g . j e t b r a i n s . j p s . i n c r e m e n t a l . I n c P r o j e c t B u i l d e r . b u i l d ( I n c P r o j e c t B u i l d e r . j a v a : 183 ) a t o r g . j e t b r a i n s . j p s . c m d l i n e . B u i l d R u n n e r . r u n B u i l d ( B u i l d R u n n e r . j a v a : 132 ) a t o r g . j e t b r a i n s . j p s . c m d l i n e . B u i l d S e s s i o n . r u n B u i l d ( B u i l d S e s s i o n . j a v a : 302 ) a t o r g . j e t b r a i n s . j p s . c m d l i n e . B u i l d S e s s i o n . r u n ( B u i l d S e s s i o n . j a v a : 132 ) a t o r g . j e t b r a i n s . j p s . c m d l i n e . B u i l d M a i n OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at org.jetbrains.jps.incremental.IncProjectBuilder.sendElapsedTimeMessages(IncProjectBuilder.java:454) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:425) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132) at org.jetbrains.jps.cmdline.BuildMain OfRef.evaluateSequential(ForEachOps.java:173)atjava.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)atjava.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)atorg.jetbrains.jps.incremental.IncProjectBuilder.sendElapsedTimeMessages(IncProjectBuilder.java:454)atorg.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:425)atorg.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)atorg.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)atorg.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)atorg.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)atorg.jetbrains.jps.cmdline.BuildMainMyMessageHandler.lambdachannelRead0 0 ( B u i l d M a i n . j a v a : 219 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1144 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r 0(BuildMain.java:219) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor 0(BuildMain.java:219)atjava.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)atjava.base/java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1623)

二、报错原因

  • 这个报错是由于访问权限问题导致的。在Java中,通过反射机制可以修改对象的访问权限,使得本来不可访问的方法、字段等变得可访问。但是,对于某些特定的Java类和方法,由于安全原因,它们被设置为不可访问。
  • 在这个报错中,出现了"java.util.ResourceBundle.setParent(java.util.ResourceBundle)"方法无法访问的问题。报错信息中提到,模块"java.base"没有将"java.util"打开(opens)给未命名模块。在Java 9及以上版本中,模块系统被引入,用于对Java类和包进行更严格的封装和访问控制。模块可以选择性地将自己的包和类对外部模块开放,以控制访问权限。

三、解决方法

  • idea增加jvm启动参数

  • --add-opens java.base/java.util=ALL-UNNAMED

四、更多报错解决方案

  • 更加对应的错误添加对应的jvm启动参数
java 复制代码
--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
相关推荐
学会沉淀。2 分钟前
Docker学习
java·开发语言·学习
如若1233 分钟前
对文件内的文件名生成目录,方便查阅
java·前端·python
初晴~33 分钟前
【Redis分布式锁】高并发场景下秒杀业务的实现思路(集群模式)
java·数据库·redis·分布式·后端·spring·
黑胡子大叔的小屋1 小时前
基于springboot的海洋知识服务平台的设计与实现
java·spring boot·毕业设计
ThisIsClark1 小时前
【后端面试总结】深入解析进程和线程的区别
java·jvm·面试
雷神乐乐2 小时前
Spring学习(一)——Sping-XML
java·学习·spring
小林coding3 小时前
阿里云 Java 后端一面,什么难度?
java·后端·mysql·spring·阿里云
V+zmm101343 小时前
基于小程序宿舍报修系统的设计与实现ssm+论文源码调试讲解
java·小程序·毕业设计·mvc·ssm
文大。3 小时前
2024年广西职工职业技能大赛-Spring
java·spring·网络安全
一只小小翠3 小时前
EasyExcel 模板+公式填充
java·easyexcel