100% multiplatform, 100% compile time reflection for Kotlin. Includes:
- Inspecting classes, functions, and properties
- Top-level declaration support
- Annotation instances
- Function invocation, including
suspendfunctions ischecking and casting- JVM-like proxies
- Reflecting over dependencies (whether they use Inspekt or not)
- Seamless reflection over Java classes
- GraalVM compatible out of the box (I think, it's not tested yet)
To use Inspekt, just apply the Gradle plugin:
plugins {
id("dev.rnett.inspekt") version "<version>" // see the Maven Central badge above
}and call inspekt from your code:
val fooClass = inspekt(Foo::class)
foo.function("bar").invoke {
dispatchReceiver = Foo()
}Warning
Compatibility with other compiler plugins depends on the plugin and is not at all guaranteed or even expected to work.
Use at your own risk.
It will most likely work for declarations generated by other plugins if you use the compiler plugin ordering parameter
to ensure Inspekt (which has id dev.rnett.inspekt.compiler-plugin) runs after the other plugin(s).
It is 0% compatible with @Composable functions.
More detailed documentation is available at https://inspekt.rnett.dev/latest/.
Snapshot version docs are available at https://inspekt.rnett.dev/snapshot/, if there is currently a next-version snapshot build.
This library has been initially released as alpha because it depends on a number of compiler internals. However, I plan no significant changes and will strive to avoid any backwards incompatible changes.
Some basic examples are located in the examples directory.