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
After migration from KSP1 to KSP2 I have a problem when I try to read a parameter of an annotation on a class, which has a default value. The annotation is defined like this:
@Target(AnnotationTarget.CLASS)
public annotation class SimpleHtmlComponent(val tagName: String, val withText: Boolean = false)
and the code of the processor looks like this:
val simpleHtmlComponent = classDeclaration.getAnnotationsByType(SimpleHtmlComponent::class).first()
val tagName = simpleHtmlComponent.tagName
val withText = simpleHtmlComponent.withText
The last line throws the exception:
Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
at com.google.devtools.ksp.UtilsKt.createInvocationHandler$lambda$8(utils.kt:587)
at jdk.proxy10/jdk.proxy10.$Proxy212.withText(Unknown Source)
at dev.kilua.ksp.KiluaProcessor.process(KiluaProcessor.kt:62)
at com.google.devtools.ksp.impl.KotlinSymbolProcessing$execute$1$1.invoke(KotlinSymbolProcessing.kt:581)
at com.google.devtools.ksp.impl.KotlinSymbolProcessing$execute$1$1.invoke(KotlinSymbolProcessing.kt:579)
at ksp.com.google.devtools.ksp.common.IncrementalContextBase.closeFilesOnException(IncrementalContextBase.kt:404)
at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:579)
at com.google.devtools.ksp.impl.KSPLoader$Companion.loadAndRunKSP(KSPLoader.kt:37)
at com.google.devtools.ksp.impl.KSPLoader.loadAndRunKSP(KSPLoader.kt)
The exception happened when it tries to get the default value of the annotation in a KMP build. It works on KSP1 by accident, where 1) JVM is part of the targets, and 2) KSP1 didn't check the targets and unconditionally tries to load the annotation as a Java class instance. Therefore it works when JVM is present in KSP1.
After migration from KSP1 to KSP2 I have a problem when I try to read a parameter of an annotation on a class, which has a default value. The annotation is defined like this:
and the code of the processor looks like this:
The last line throws the exception:
To reproduce:
ksp2issue
branch./gradlew allTest --stacktrace
The annotations are in the
modules/kilua-annotations
module. The processor in theplugins/kilua-ksp-processor
module.The same code works fine with KSP1.
The text was updated successfully, but these errors were encountered: