Kairo Reflect
kairo-reflect extends Kotlin’s reflection library.
KairoType
Section titled “KairoType”JVM/Kotlin reflection is powerful,
but the standard APIs are fragmented
across Class<T>, KClass<T>, Type, and KType.
kairo-reflect unifies these into a single, runtime-rich abstraction: KairoType<T>.
- Full generic fidelity:
Preserves type arguments at runtime (
List<String>, not justList<*>). - Unified access: Seamlessly move between Java and Kotlin reflection models.
- Runtime inference: Extract generic parameter types without boilerplate.
- Safer metaprogramming: Fewer lossy conversions, fewer reflection edge cases.
This makes dynamic frameworks (serialization, dependency injection, query builders) more reliable and maintainable.
Installation
Section titled “Installation”Install kairo-reflect.
You don’t need to install Kotlin’s reflection library separately —
it’s included by default.
dependencies { implementation("software.airborne.kairo:kairo-reflect")}kairoType
Section titled “kairoType”Capture a rich KairoType<T> that includes context from all major reflection models.
val type: KairoType<T> = kairoType<MyClass<String>>()
val javaClass: Class<T> = type.javaClassval kotlinClass: KClass<T> = type.kotlinClassval javaType: Type = type.javaTypeval kotlinType: KType = type.kotlinTypeKairoType.from()
Section titled “KairoType.from()”Infer a generic type parameter at runtime with no manual plumbing.
abstract class MyClass<T> { val type: KairoType<T> = KairoType.from(MyClass::class, 0, this::class)}