Skip to content

Compatibility issue: KaptJavaCompiler cannot access JavaCompiler with Java 21 #2

@igperez-ar

Description

@igperez-ar

Description

When building the project using Java 21 with the current Kotlin version, the following error occurs:

superclass access check failed: 
  class org.jetbrains.kotlin.kapt3.base.javac.KaptJavaCompiler (in unnamed module @0x36ee51e2)
  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 @0x36ee51e2
  	at java.base/

Environment

  • Java version: 21
  • Kotlin version: 1.9.10
  • Gradle version: 8.0
  • Operating System: MacOS 15.3.1 (24D70)

Steps to Reproduce

  1. Set up the project having the SDK set globally with Java 21.
  2. Use the specified Kotlin version.
  3. Run the build process.

Expected Behavior

The project should build successfully without compatibility issues.

Actual Behavior

The build fails with the superclass access check failed error due to module access restrictions in Java 21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions