报错:Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not “opens java.lang” to unnamed module @19d37183
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at ma.glasnost.orika.converter.builtin.CloneableConverter.(CloneableConverter.java:64)
at ma.glasnost.orika.converter.builtin.CloneableConverter$Builtin.(CloneableConverter.java:221)
at ma.glasnost.orika.converter.builtin.BuiltinConverters.register(BuiltinConverters.java:135)
at ma.glasnost.orika.impl.DefaultMapperFactory.build(DefaultMapperFactory.java:1280)
at ma.glasnost.orika.impl.DefaultMapperFactory.getMapperFacade(DefaultMapperFactory.java:883)
at cc.balabala.aladdin.common.util.bean.OrikaBeanMapper.(OrikaBeanMapper.java:31)
… 165 common frames omitted
解决方法:
在idea中配置jvm参数:
–add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.base/sun.reflect.generics.parser=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-exports=java.base/sun.util.calendar=ALL-UNNAMED --add-exports=java.base/sun.security.action=ALL-UNNAMED --add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED
jar包运行方式(注意参数要放在-jar前面,否则无效):
java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED -jar xxx.jar
常见的模块:
–add-opens=java.base/java.lang=ALL-UNNAMED
–add-opens=java.base/java.lang.reflect=ALL-UNNAMED
–add-opens=java.base/java.util=ALL-UNNAMED
–add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
–add-opens=java.base/java.io=ALL-UNNAMED
–add-opens=java.management/javax.management=ALL-UNNAMED
–add-opens=java.desktop/sun.font=ALL-UNNAMED
–add-opens=java.base/sun.reflect.generics.parser=ALL-UNNAMED
–add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
–add-opens=java.base/java.time=ALL-UNNAMED
–add-exports=java.base/sun.util.calendar=ALL-UNNAMED
–add-exports=java.base/sun.security.action=ALL-UNNAMED
–add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED