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

com.sun.tools.javac.util.Context class can't be found #277

Closed
mars885 opened this issue Aug 4, 2024 · 1 comment
Closed

com.sun.tools.javac.util.Context class can't be found #277

mars885 opened this issue Aug 4, 2024 · 1 comment

Comments

@mars885
Copy link

mars885 commented Aug 4, 2024

Greetings.

I'm in a process of migrating my lib to the Kotlin 2.0 version and I've stumbled upon a blocker where my Java annotation processor's tests fail (both locally and on CI) with the following message:

e: [kapt] 'com.sun.tools.javac.util.Context' class can't be found ('tools.jar' is absent in the plugin classpath). Kapt won't work.

The following env & dependencies are used for tests:

  • Kotlin: 2.0.0
  • KSP: 2.0.0-1.0.24
  • dev.zacsweers.kctfork:ksp:0.5.1
  • JDK: corretto-1.8.0_412
  • kapt4: false

The testing lib is set up like this:

private fun setupCompilation(
    sourceFiles: List<SourceFile>,
    processorType: ProcessorType,
): KotlinCompilation {
    val compilation = KotlinCompilation().apply {
        sources = sourceFiles
        verbose = false
        inheritClassPath = true
        languageVersion = "1.9"

        when (processorType) {
            ProcessorType.JAVAC -> annotationProcessors = listOf(HiltBinderJavacProcessor())
            ProcessorType.KSP -> configureKsp {
                symbolProcessorProviders.add(HiltBinderKspProcessor.Provider())
            }
        }
    }

    return compilation
}

The jdkHome and toolsJar properties from the KotlinCompilation class resolve to the correct paths when debugging:

  • jdkHome -> /Users/paul/Library/Java/JavaVirtualMachines/corretto-1.8.0_412/Contents/Home
  • toolsJar -> /Users/paul/Library/Java/JavaVirtualMachines/corretto-1.8.0_412/Contents/Home/lib/tools.jar

I've also verified that tools.jar does in fact exists in the path /Users/paul/Library/Java/JavaVirtualMachines/corretto-1.8.0_412/Contents/Home/lib/tools.jar.

Do you have an idea what's causing this? I've searched the Internet for answers, but nothing worked in my case.

@ZacSweers
Copy link
Owner

@ZacSweers ZacSweers closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2024
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

No branches or pull requests

2 participants