`Unrecognized Vm Option 'Cmsclassunloadingenabled'` After Switching to Java 17

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
4
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article