Lazy load UNIT_TYPE · Issue #580 · FasterXML/jackson-module-kotlin (original) (raw)
Use case
We often use ObjectMapper for just json parsing and not full object mapping. Initialization of KotlinAnnotationIntrospector
currently causes a delay because of Kotlin Reflection loading. We would like to eliminate this delay until it is really needed.
Describe the solution you'd like
Replace
val UNIT_TYPE: KType = Unit::class.createType()
with
val UNIT_TYPE: KType by lazy { Unit::class.createType() }
Describe alternatives you've considered
Alternative would be avoiding creating UNIT_TYPE
altogther and replacing single usage returnType == UNIT_TYPE
with checking FQN since it is well-known.