I've got a question about kotlinpoet: Why is `Ann...
# squarelibraries
l
I've got a question about kotlinpoet: Why is
AnnotationSpec.get(annotation: Annotation, includeDefaultValues: Boolean)
annotated with
@DelicateKotlinPoetApi
? The message says "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.". However types in annotation are already pretty restricted in Kotlin due to JVM restrictions (no `null`s, only primitives, strings, enums, arrays, classes and other annotations). So I wasn't able to think of a situation that Java reflection wouldn't be able to extract all information needed for that function. Is there a situation that wouldn't work with Java reflection? And if not, is there another reason for the annotation?
OK, found a case myself:
Copy code
annotation class WithUInt(
    val value: UInt,
)

// will produce @WithUInt(value = 1)
// (missing 'u' suffix)
AnnotationSpec.get(WithUInt(1u))

// will produce @WithUInt(value = -1)
// because of int representation on jvm
AnnotationSpec.get(WithUInt(UInt.MAX_VALUE))