After changing the Java version to 17 I can't build the Gradle project.
I am using Gradle 7.3.1 version and have the following line in Gradle properties:
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xms1g -Xmx4g -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled
then I got the following error
Unrecognized VM option 'CMSClassUnloadingEnabled'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
If I remove -XX:+CMSClassUnloadingEnabled
then I got this error:
Unable to make field private int java.lang.reflect.Field.modifiers accessible: module java.base does not "opens java.lang.reflect" to unnamed module @1b9ee3e0
Unable to make field private int java.lang.reflect.Field.modifiers accessible: module java.base does not "opens java.lang.reflect" to unnamed module @1b9ee3e0
Yeah you are right that's because of AspectJ
Assuming that you are using AspectJ load-time weaving (LTW) rather than compile-time weaving, maybe you ought to read the AspectJ release notes for each version since 1.9.7, supporting Java 16+:
Use LTW on Java 16+
Please note that if you want to use load-time weaving on Java 16+, the weaving agent collides with JEP 396 (Strongly Encapsulate JDK Internals by Default) and related subsequent JEPs. Therefore, you need to set the JVM parameter
--add-opens java.base/java.lang=ALL-UNNAMED
in order to enable aspect weaving. This is due to the fact that the weaver uses internal APIs for which we have not found an adequate replacement yet when defining classes in different classloaders.
Update: Since AspectJ 1.9.21.1, --add-opens
is no longer necessary, see e.g. the release notes here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With