kClassFromName

expect fun kClassFromName(qualifiedName: String): Optional<out KClass<*>>

Resolves qualifiedName (which must match CLASS_NAME_PATTERN) into the KClass it names, or Optional.none if no such type can be found. Backs TypeFactory.default.

On the JVM this also recognizes Kotlin's own standard-library type names (via an internal name table) before falling back to Class.forName, retrying with .-to-$ substitutions to find nested classes; results are cached. On Kotlin/JS, qualifiedName must be of the form <module>:<qualified name> and is resolved via Node's require, so this only works in a Node.js-hosted environment.

Throws

actual fun kClassFromName(qualifiedName: String): Optional<out KClass<*>>

Resolves qualifiedName (which must match CLASS_NAME_PATTERN) into the KClass it names, or Optional.none if no such type can be found. Backs TypeFactory.default.

On the JVM this also recognizes Kotlin's own standard-library type names (via an internal name table) before falling back to Class.forName, retrying with .-to-$ substitutions to find nested classes; results are cached. On Kotlin/JS, qualifiedName must be of the form <module>:<qualified name> and is resolved via Node's require, so this only works in a Node.js-hosted environment.

Throws

actual fun kClassFromName(qualifiedName: String): Optional<out KClass<*>>

Resolves qualifiedName (which must match CLASS_NAME_PATTERN) into the KClass it names, or Optional.none if no such type can be found. Backs TypeFactory.default.

On the JVM this also recognizes Kotlin's own standard-library type names (via an internal name table) before falling back to Class.forName, retrying with .-to-$ substitutions to find nested classes; results are cached. On Kotlin/JS, qualifiedName must be of the form <module>:<qualified name> and is resolved via Node's require, so this only works in a Node.js-hosted environment.

Throws