这篇文章上次修改于 2151 天前,可能其部分内容已经发生变化,如有疑问可询问作者。 ### java 11 报错如下: ```java java.lang.reflect.InaccessibleObjectException: Unable to make public void jdk.internal.ref.Cleaner.clean() accessible: module java.base does not "exports jdk.internal.ref" to unnamed module @efde75f at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198) at java.base/java.lang.reflect.Method.setAccessible(Method.java:192) at com.dianping.cat.util.CleanupHelper.cleanup(CleanupHelper.java:51) at com.dianping.cat.message.internal.MessageIdFactory.close(MessageIdFactory.java:71) at com.dianping.cat.message.internal.MessageIdFactory$1.run(MessageIdFactory.java:266) ``` ### 这个是java缺少模块导致,解决办法如下,java 启动加入参数 ```java --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED ``` ### 参考文档: https://stackoverflow.com/questions/47891295/cannot-access-a-member-of-class-java-nio-directbytebuffer-in-module-java-base https://stackoverflow.com/questions/40313090/java-9-options-add-exports-vs-xaddexports-not-recognized
没有评论