Unable to make field private static final java.util.Map java.lang.ProcessEnvironment.theCaseInsensitiveEnvironment accessible: module java.base does not "opens java.lang" to unnamed module

I've had a similar problem with an old BungeeCord plugin, which used Gradle 4.10. In my case - it seems like that old Gradle doesn't work properly with Java 16, so I've manually changed contents of file to use Gradle 7.0.gradle/wrapper/gradle-wrapper.properties

Old file:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

New file:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
Now it works ok, no more Gradle errors.