Forrest Pangborn
04/10/2025, 1:32 PMTypeName
instances from KType
values, using the asTypeName()
extension to KType
provided by KotlinPoet.
Looks like the implementation of asTypeName()
relies on kotlin-reflect
(the typeParameters
property on KClass
).
In KSP1, using asTypeName()
like this works but with KSP2 I’m getting an exception:
Caused by: kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:88)
at kotlin.jvm.internal.ClassReference.getTypeParameters(ClassReference.kt:38)
at com.squareup.kotlinpoet.ParameterizedTypeName$Companion.get$kotlinpoet(ParameterizedTypeName.kt:236)
at com.squareup.kotlinpoet.ParameterizedTypeNames.asTypeName(ParameterizedTypeName.kt:275)
My processor already includes kotlin-reflect
as an implementation dependency – and I've tried adding it for the consumer of the processor too, but same failure.
Running with latest KSP version but in legacy mode (via useKsp2 = false
) works fine as well – so seems definitely an issue with KSP2.
Anyone have any suggestions on other things I can try?sbelloz
05/15/2025, 2:32 PM2.1.20-2.0.0