Behind the mirror, Kotlin Reflection
summary
Kotlin reflection exploration shows exactly what works and how: use KClass/KType/KFunction/KProperty to inspect constructors, nullability and suspend continuations (must use callSuspend), interoperate with Java reflection for primitives and erased types, and extract Kotlin metadata annotations D1/D2 then decode them with JvmProtoBufUtil.classDataFrom to reconstruct KFunction descriptors. Examples include property delegates that detect call sites via stacktrace or Java reflection and a safeMutableStateOf delegate that integrates SavedStateHandle — both practical and working, with caveats about performance and no direct private-field API.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 2:10Kotlin reflection basics
- 4:55KClass and members
- 8:46KFunction capabilities
- 12:58KProperty and delegates
- 18:23Coroutines with reflection
- 20:11Java interoperability
- 23:03How reflection works
- 30:17Reflection in testing
- 33:48Limitations and performance








