I’ve been getting stuck into upskilling in Kotlin. Mostly for TeamCity build automation and trying to produce quality tested code in a space where automation was retrofitted in.

Today’s fun little problem was the error message:

Runtime error RootProjectId: kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns$3[92]: java.lang.AssertionError: Built-in class kotlin.Any is not found

The canonical stack overflow question that (at the time of writing this) had no answer: https://stackoverflow.com/questions/67199546/why-am-i-getting-java-lang-assertionerror-built-in-class-kotlin-any-is-not-fou

The repro was the simplest piece of code in the end. I was even able to point it at a teamcity class over my own (Project):

import kotlin.reflect.full.declaredMemberProperties

val props = Project::class.declaredMemberProperties

(For reference, i tried a few version configurations, but they were mainly kotlin version 1.3.31 teamcity version 2019.2 and kotlin version 1.4.31 and teamcity version 202.2.2)

At this point in time and with some further testing, I’ve come to the conclusion that reflection just isn’t supported on teamcity with Kotlin. I’ve found one or two Issue links to back that up too: https://youtrack.jetbrains.com/issue/TW-59901

(¬_¬ )

If anyone else managed to find a solution that works, or if any future version adds the missing puzzle pieces that make this work, I would be greatful to hear.

For now, I have replaced the reflection with good ol’ verbose fragile code.

Luckily, the tests allow reflection no problem so at least the fragility of this case is covered. If someone adds a property then at least a test fails until the verbose code had been amended.