Is it possible to get the primary constructor of a...
# reflect
s
Is it possible to get the primary constructor of a Kotlin class from Java code? I have found
kotlin.jvm.JvmClassMappingKt.getKotlinClass(clazz)
which allow me to get constructors but not the primary one (at least not without using internal classes). I have tried to expose an util function like
fun getPrimaryConstructor(clazz: Class<*>) = clazz.kotlin.primaryConstructor?.javaConstructor
but then compilation fails (at least on command line) because in my module Java code depends on Kotlin and Kotlin code depends on Java code. I would like to find a solution that do not requires the creation of a dedicated Kotlin module that would expose java friendly API to achieve such functionnality. Any thoughts?