Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KotlinKapt fails on Java 21 with java.lang.IllegalAccessError #1062

Closed
cheister opened this issue Oct 28, 2023 · 1 comment · Fixed by #1069
Closed

KotlinKapt fails on Java 21 with java.lang.IllegalAccessError #1062

cheister opened this issue Oct 28, 2023 · 1 comment · Fixed by #1069

Comments

@cheister
Copy link
Contributor

cheister commented Oct 28, 2023

When running with Java 21 the KotlinKapt action fails with

exception: java.lang.IllegalAccessError: superclass access check failed: class org.jetbrains.kotlin.kapt3.base.javac.KaptJavaCompiler (in unnamed module @0x229fa008) cannot access class com.sun.tools.javac.main.JavaCompiler (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.main to unnamed module @0x229fa008

For now, the workaround is to add the following to the .bazelrc file

build --worker_extra_flag='KotlinKapt=--wrapper_script_flag=--jvm_flags=--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED'

but would be nice to add this flag to the jvm_opts for KotlinKapt

@manuelddahmen
Copy link

I have the same problem since this morning with Java 21, Gradle 8.7 and Kotlin 1.9.20
I searched for solutions and try to fix this issue on my computer.
Do you have a solution for Android Studio on Windows 11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants