Skip to content

[KSP2] NPE when getting annotation arguments on non-Jvm targets #1823

@DennisTsar

Description

@DennisTsar

Calling KSAnnotation.arguments for an annotation with arguments fails with KSP2 on non-Jvm targets with the following error:

java.lang.NullPointerException: null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
	at com.google.devtools.ksp.impl.symbol.kotlin.UtilKt.getDefaultValue(util.kt:430)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$defaultArguments$2.invoke(KSAnnotationImpl.kt:88)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$defaultArguments$2.invoke(KSAnnotationImpl.kt:71)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl.getDefaultArguments(KSAnnotationImpl.kt:71)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$arguments$2.invoke(KSAnnotationImpl.kt:65)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$arguments$2.invoke(KSAnnotationImpl.kt:62)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl.getArguments(KSAnnotationImpl.kt:62)

Repro: DennisTsar@8449e19
This seems similar to #1798 , but does not involve Java in any way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2affects usability but not blocks usersbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions