toClassOrNull

@JvmName(name = "createOrNull")
fun String.toClassOrNull(loader: ClassLoader? = null, initialize: Boolean = false): Class<Any>?

Convert String class name to Class with ClassLoader and initialize.

Receiver

the class name to be converted.

Return

Class or null if the class not found.

Parameters

loader

ClassLoader to load the class, default is ClassLoaderProvider.classLoader.

initialize

whether to initialize the class with loader, default is false.

See also


@JvmName(name = "createOrNullTyped")
fun <T : Any> String.toClassOrNull(loader: ClassLoader? = null, initialize: Boolean = false): Class<T>?

Convert String class name to Class with ClassLoader and initialize.

Return

Class<T> or null if the class not found or type cast failed.

See also


@JvmName(name = "toClassTypedOrNull")
fun <T : Any> Type.toClassOrNull(): Class<T>?

Safely convert Type to Class or return null if it fails.

Receiver

the Type to be converted.

Return

Class<T> or null.

See also


Safely convert Type to Class or return null if it fails.

Return

Class or null.

See also