Java 16 …

JEP 396: Strongly Encapsulate JDK Internals by Default

主要影响是部分基于反射的功能。比如lombok,

解决方法是升级lombok版本到 1.18.20

相关:

https://projectlombok.org/changelog

https://github.com/rzwitserloot/lombok/issues/2681

针对:

java.lang.reflect.InaccessibleObjectException: Unable to make {member} accessible: module {A} does not “opens {package} ” to {B}
解决方法是在Java的VM参数中添加 --add-opens java.base/java.lang=ALL-UNNAMED
参考:https://www.lwohvye.com/2021/04/09/java-lang-reflect-inaccessibleobjectexception-unable-to-make-member-accessible-module-a-does-not-opens-package-to-b/

JEP 395: Records

关于Records 和 lombok,参考:https://stackoverflow.com/questions/61306802/lombok-getter-setter-vs-java-14-record/61325018#61325018

Leave a Reply

Your email address will not be published. Required fields are marked *

lWoHvYe 无悔,专一