How can I solve this problem of getting execution failure?

Execution failed for task ‘:app:compileDebugJavaWithJavac’.

java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x16b68a6a) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x16b68a6a