KClass

expect interface KClass<T : Any> : KClassifier(source)

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.0

Parameters

T

the type of the class.

actual interface KClass<T : Any> : KClassifier(source)

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.1

Parameters

T

the type of the class.

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.0

Parameters

T

the type of the class.

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.3

Parameters

T

the type of the class.

actual interface KClass<T : Any> : KClassifier(source)

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.8

Parameters

T

the type of the class.

actual interface KClass<T : Any> : KClassifier(source)

Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class syntax. See the Kotlin language documentation for more information.

Since Kotlin

1.8

Parameters

T

the type of the class.

Properties

Link copied to clipboard
abstract val annotations: List<Annotation>

Annotations which are present on this element.

Since Kotlin 1.0
Link copied to clipboard

All constructors declared in this class.

Since Kotlin 1.0
Link copied to clipboard
abstract val isAbstract: Boolean

true if this class is abstract.

Since Kotlin 1.1
Link copied to clipboard
abstract val isCompanion: Boolean

true if this class is a companion object. See the Kotlin language documentation for more information.

Since Kotlin 1.1
Link copied to clipboard
abstract val isData: Boolean

true if this class or object has the data keyword. For more information, see data class and data object in the Kotlin language documentation.

Since Kotlin 1.1
Link copied to clipboard
abstract val isFinal: Boolean

true if this class is final.

Since Kotlin 1.1
Link copied to clipboard
abstract val isFun: Boolean

true if this class is a Kotlin functional interface.

Since Kotlin 1.4
Link copied to clipboard
abstract val isInner: Boolean

true if this class is an inner class. See the Kotlin language documentation for more information.

Since Kotlin 1.1
Link copied to clipboard
abstract val isOpen: Boolean

true if this class is open.

Since Kotlin 1.1
Link copied to clipboard
abstract val isSealed: Boolean

true if this class is sealed. See the Kotlin language documentation for more information.

Since Kotlin 1.1
Link copied to clipboard
abstract val isValue: Boolean

true if this class is a value class.

Since Kotlin 1.5
Link copied to clipboard
@get:JvmName(name = "getJavaClass")
val <T> KClass<T>.java: Class<T>

Returns a Java Class instance corresponding to the given KClass instance.

Since Kotlin 1.0
Link copied to clipboard
@get:JvmName(name = "getRuntimeClassOfKClassInstance")
val <T : Any> KClass<T>.javaClass: Class<KClass<T>>
Since Kotlin 1.0
Link copied to clipboard

Returns a Java Class instance corresponding to the given KClass instance. In case of primitive types it returns corresponding wrapper classes.

Since Kotlin 1.0
Link copied to clipboard

Returns a Java Class instance representing the primitive type corresponding to the given KClass if it exists.

Since Kotlin 1.0
Link copied to clipboard
val <T : Any> KClass<T>.js: JsClass<T>

Obtains a constructor reference for the given KClass.

Since Kotlin 1.1
Link copied to clipboard
abstract override val members: Collection<KCallable<*>>

All functions and properties accessible in this class, including those declared in this class and all of its superclasses. Does not include constructors.

Since Kotlin 1.0
Link copied to clipboard
abstract val nestedClasses: Collection<KClass<*>>

All classes declared inside this class. This includes both inner and static nested classes.

Since Kotlin 1.0
Link copied to clipboard
abstract val objectInstance: T?

The instance of the object declaration, or null if this class is not an object declaration.

Since Kotlin 1.0
Link copied to clipboard
expect abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.0
actual abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.1
actual abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.0
actual abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.3
actual abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.8
actual abstract val qualifiedName: String?

The fully qualified dot-separated name of the class, or null if the class is local or a class of an anonymous object.

Since Kotlin 1.8
Link copied to clipboard
abstract val sealedSubclasses: List<KClass<out T>>

The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise.

Since Kotlin 1.3
Link copied to clipboard
expect abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.0
actual abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.1
actual abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.0
actual abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.3
actual abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.8
actual abstract val simpleName: String?

The simple name of the class as it was declared in the source code, or null if the class has no name (if, for example, it is a class of an anonymous object).

Since Kotlin 1.8
Link copied to clipboard
abstract val supertypes: List<KType>

The list of immediate supertypes of this class, in the order they are listed in the source code.

Since Kotlin 1.1
Link copied to clipboard

The list of type parameters of this class. This list does not include type parameters of outer classes.

Since Kotlin 1.1
Link copied to clipboard
abstract val visibility: KVisibility?

Visibility of this class, or null if its visibility cannot be represented in Kotlin.

Since Kotlin 1.1

Functions

Link copied to clipboard
fun <T : Any> KClass<T>.cast(value: Any?): T

Casts the given value to the class represented by this KClass object. Throws an exception if the value is null or if it is not an instance of this class.

Since Kotlin 1.4
Link copied to clipboard

Creates a new instance of the class, calling a constructor which either has no parameters or all parameters of which have a default value. If there are no or many such constructors, an exception is thrown.

Since Kotlin 1.9
Link copied to clipboard
expect abstract operator override fun equals(other: Any?): Boolean
Since Kotlin 1.0
actual abstract operator override fun equals(other: Any?): Boolean

Returns true if this KClass instance represents the same Kotlin class as the class represented by other. On JVM this means that all of the following conditions are satisfied:

Since Kotlin 1.1
actual abstract operator override fun equals(other: Any?): Boolean

Returns true if this KClass instance represents the same Kotlin class as the class represented by other. On JVM this means that all of the following conditions are satisfied:

Since Kotlin 1.0
actual abstract operator override fun equals(other: Any?): Boolean

Returns true if this KClass instance represents the same Kotlin class as the class represented by other. On JVM this means that all of the following conditions are satisfied:

Since Kotlin 1.3
actual abstract operator override fun equals(other: Any?): Boolean
Since Kotlin 1.8
actual abstract operator override fun equals(other: Any?): Boolean
Since Kotlin 1.8
Link copied to clipboard

If T is an @AssociatedObjectKey-annotated annotation class and this class is annotated with @T (S::class), returns object S.

Since Kotlin 1.1

If T is an @AssociatedObjectKey-annotated annotation class and this class is annotated with @T (S::class), returns object S.

Since Kotlin 1.3

If T is an @AssociatedObjectKey-annotated annotation class and this class is annotated with @T (S::class), returns object S.

Since Kotlin 1.8

If T is an @AssociatedObjectKey-annotated annotation class and this class is annotated with @T (S::class), returns object S.

Since Kotlin 1.8
Link copied to clipboard
expect abstract override fun hashCode(): Int
Since Kotlin 1.0
actual abstract override fun hashCode(): Int
Since Kotlin 1.1
actual abstract override fun hashCode(): Int
Since Kotlin 1.0
actual abstract override fun hashCode(): Int
Since Kotlin 1.3
actual abstract override fun hashCode(): Int
Since Kotlin 1.8
actual abstract override fun hashCode(): Int
Since Kotlin 1.8
Link copied to clipboard
expect abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.1
actual abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.1
actual abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.1
actual abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.3
actual abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.8
actual abstract fun isInstance(value: Any?): Boolean

Returns true if value is an instance of this class on a given platform.

Since Kotlin 1.8
Link copied to clipboard
fun <T : Any> KClass<T>.safeCast(value: Any?): T?

Casts the given value to the class represented by this KClass object. Returns null if the value is null or if it is not an instance of this class.

Since Kotlin 1.4