rules_kotlin
rules_kotlin copied to clipboard
`Exception in thread "main" java.lang.NoClassDefFoundError: dagger/internal/Preconditions` with JDK 20 and 21
Hello,
When using rules_kotlin (tip) with JDK 21 and 20, I see this error:
ERROR: <foo>/lab/lang/kt/BUILD.bazel:140:12: KotlinCompile //lab/lang/kt:types_test_kt_ { kt: 1, java: 0, srcjars: 0 } for darwin_arm64 failed: Worker process did not return a WorkResponse:
---8<---8<--- Start of log, file at /Volumes/dumroo/.cache/bazel/7d62ec18ea2c2975e10db310a8227229/bazel-workers/worker-11-KotlinCompile.log ---8<---8<---
Exception in thread "main" java.lang.NoClassDefFoundError: dagger/internal/Preconditions
at io.bazel.kotlin.builder.DaggerKotlinBuilderComponent$Builder.toolchain(DaggerKotlinBuilderComponent.java:43)
at io.bazel.kotlin.builder.DaggerKotlinBuilderComponent$Builder.toolchain(DaggerKotlinBuilderComponent.java:38)
at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:33)
at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:29)
at io.bazel.worker.Worker$Companion.from(Worker.kt:31)
at io.bazel.kotlin.builder.cmd.Build.main(Build.kt:29)
Caused by: java.lang.ClassNotFoundException: dagger.internal.Preconditions
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
... 6 more
---8<---8<--- End of log ---8<---8<---
INFO: Elapsed time: 119.046s, Critical Path: 86.61s
INFO: 961 processes: 215 internal, 654 darwin-sandbox, 5 local, 87 worker.
ERROR: Build did NOT complete successfully
This error does not occur with JDK 17. Not sure why that is the case though.
This seems to be "fixed" by removing the shade on rule dagger.** io.bazel.kotlin.builder.dagger.@1, though eventually the issue downstream re-appears that I imagine inspired that jarjar rule.