Petter Måhlén
07/30/2020, 7:26 AMClassPreloadingUtils.preloadClasses
in https://github.com/bazelbuild/rules_kotlin/blob/master/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt#L70, that means that the Reflection
class gets initialised at a point in time when reflection isn't added?
c) or something completely different. There's a lot of ground to cover in all the Kotlin compilation ecosystem as well as the Bazel stuff, and I'm new to both.
Help very much appreciated, if possible!Roman Artemev [JB]
07/30/2020, 9:12 AMkotlin-reflection.jar
been provided at runtime? By default reflection support is not included in class path at runtimePetter Måhlén
07/30/2020, 9:16 AMCompilation failure: compile phase failed:
warning: some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.50/stamped_kotlin-reflect-1.3.50.jar: warning: library has Kotlin runtime bundled into it
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/stamped_kotlin-stdlib-1.3.50.jar: warning: library has Kotlin runtime bundled into it
Petter Måhlén
07/30/2020, 9:18 AM--processorpath
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/com/squareup/moshi/moshi-kotlin-codegen/1.9.2/stamped_moshi-kotlin-codegen-1.9.2.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/com/squareup/kotlinpoet/1.4.4/stamped_kotlinpoet-1.4.4.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/stamped_kotlin-stdlib-1.3.50.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/stamped_annotations-13.0.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/stamped_kotlin-stdlib-common-1.3.50.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.50/stamped_kotlin-stdlib-jdk7-1.3.50.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.50/stamped_kotlin-reflect-1.3.50.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/com/squareup/okio/okio/1.16.0/stamped_okio-1.16.0.jar
bazel-out/host/bin/external/maven/v1/https/repo1.maven.org/maven2/com/squareup/moshi/moshi/1.9.2/stamped_moshi-1.9.2.jar
Petter Måhlén
07/30/2020, 9:34 AMkotlin.jvm.internal.Reflection
class gets loaded at a point in time before kotlin-reflect.jar is available on the classpath, or so. I looked inside the file listed above and it seems to have the right things in it, including the kotlin.reflect.jvm.internal.ReflectionFactoryImpl
classHanno
07/30/2020, 2:20 PMPetter Måhlén
07/31/2020, 8:11 AMrules_kotlin
, which invokes the Kotlin compiler through https://github.com/bazelbuild/rules_kotlin/blob/master/src/main/kotlin/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt, and creates a classloader for it like this: https://github.com/bazelbuild/rules_kotlin/blob/master/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt#L69. I haven't been able yet to understand how those things work in detail, in particular the ClassPreloadingUtils
, but I guess that's where I'll be going next. Another thing I can try to look at is trying to run Bazel with a debugger so I can inspect things inside the process, but that seems like an uphill battle. Thanks for the confirmation that a problem like this can happen due to classloading, though! That's encouraging and might help keep me going until I figure this out 🙂Petter Måhlén
07/31/2020, 10:59 AMHanno
07/31/2020, 2:08 PMHanno
07/31/2020, 2:10 PM