You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an annotation processor that uses Kotlin multiplatform for Android, JVM, and JS targets. Everything was working fine with Kotlin 1.8.10 KSP 1.0.9 . Now using Kotlin 1.9 KSP 1.0.13 results has an exception as follows:
e: [ksp] java.lang.IllegalStateException: unhandled value type, please file a bug at https://github.com/google/ksp/issues/new
at com.google.devtools.ksp.UtilsKt.createInvocationHandler$lambda$8(utils.kt:381)
at jdk.proxy12/jdk.proxy12.$Proxy229.indices(Unknown Source)
at com.ustadmobile.lib.annotationprocessor.core.CodeBlockExtKt.addCreateTableCode(CodeBlockExt.kt:74)
The Exception is coming from the proxy which is returned by KSAnnotated.getAnnotation(class). The workaround I am using for now is to use KSAnnotation itself and "manually" instantiate the annotation class.
fun KSAnnotation.toMyAnnotation(): MyAnnotation {
if(annotationType.resolve().declaration.qualifiedName?.asString() != "mypackage.MyAnnotation")
throw IllegalArgumentException("not a myannotation!")
return MyAnnotation(
name = arguments.firstOrNull { it.name?.asString() == "name" }?.value as? String
)
}
KSValueArgument.value is not really typed: it's Any. Different parameter types (e.g. Enums, String arrays, Class arrays, etc) have different types. You can use the debugger to inspect and figure it out.
Upgrading KSP broke compilation on JS. Got java.lang.IllegalStateException: unhandled value type when using getAnnotation .
Now use KSAnnotation itself with "manual" conversion to the annotation class instead of using the proxy provided by KSP.
I have an annotation processor that uses Kotlin multiplatform for Android, JVM, and JS targets. Everything was working fine with Kotlin 1.8.10 KSP 1.0.9 . Now using Kotlin 1.9 KSP 1.0.13 results has an exception as follows:
To reproduce:
gradlew door-testdb:jsJar
It is throwing an exception when running the getAnnotation function. The exception itself is coming from here in utils.kt:
Would appreciate to know if there any fix / workaround: this is a blocker to prevent me from being able to update to Kotlin 1.9.
The text was updated successfully, but these errors were encountered: