Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Fabric Kotlin Extensions Wiki › Guides › Access Kotlin Metadata for Reflection and Type Inspection

Access Kotlin Metadata for Reflection and Type Inspection

Understanding Kotlin Metadata

Kotlin Metadata JVM provides runtime access to Kotlin-specific type information that isn't available through standard Java reflection. This is essential when your mod needs to inspect or interact with other Kotlin-based mods.

1. Import the Kotlin Metadata library into your mod code

2. Use metadata APIs to read class annotations, function signatures, and property details

3. Access Kotlin-specific features like extension functions and default parameters

Practical Applications

  • Mod compatibility: Detect features in other Kotlin mods without hardcoding class names
  • Configuration parsing: Automatically map config files to Kotlin data classes
  • Event handling: Dynamically register event listeners based on annotated methods

This is particularly useful when writing library mods or compatibility layers that need to work with multiple Kotlin-based mods. The metadata system preserves information that would otherwise be lost during compilation to bytecode.