kotlinx-reflect-lite
is an experimental attempt to replace existing kotlin-reflect
implementation
with a new lightweight and fast library, while preserving the very same API shape.
The libary is in purely experimental pre-alpha state.
It is being prototyped, evaluated and constantly changing. There is no binary or source compatibilities, and no guarantees that we won't abandon this library (including fixing any issues, answering any questions, or providing any releases) whatsoever.
Currently, the API of kotlinx-reflect-lite
is a replicated subset of kotlin-reflect
with a different package.
All core interfaces can be drop-in replaced by redacting a package, for example,
kotlin.reflect.KCallable
has a matching kotlinx.reflect.lite.KCallable
interface, as well as any
other top-level entity from kotlin.reflect
package.
The API surface of these replicated types is incomplete and allowed to throw UnsupportedOperationException
.
In addition to core interfaces, subset of reflective extensions is supported as well.
The full list is:
// Kotlin reflection to Java
ReflectJvmMapping.javaField
ReflectJvmMapping.javaGetter
ReflectJvmMapping.javaSetter
ReflectJvmMapping.javaMethod
ReflectJvmMapping.javaConstructor
ReflectJvmMapping.companionObject
ReflectJvmMapping.javaType
ReflectJvmMapping.kotlinProperty
ReflectJvmMapping.kotlinFunction
// Java reflection to Kotlin
JvmClassMapping.kotlin
JvmClassMapping.kotlinPackage
JvmClassMapping.java
// Callables support
KCallablesJvm.setAccessible
KFunction.callBy
KFunction.isSuspend
KFunction.getParameters
KCallables.callSuspend
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx.reflect.lite:1.1.0")
}
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx.reflect.lite</artifactId>
<version>1.1.0</version>
</dependency>