Package kotlin.reflect

Runtime API for /docs/reference/reflection.html

Types

AssociatedObjectKey
Link copied to clipboard
annotation class AssociatedObjectKey
annotation class AssociatedObjectKey

Makes the annotated annotation class an associated object key.

ExperimentalAssociatedObjects
Link copied to clipboard
annotation class ExperimentalAssociatedObjects
annotation class ExperimentalAssociatedObjects

The experimental marker for associated objects API.

KAnnotatedElement
Link copied to clipboard
interface KAnnotatedElement
interface KAnnotatedElement

Represents an annotated element and allows to obtain its annotations. See the Kotlin language documentation for more information.

KCallable
Link copied to clipboard
interface KCallable<out R>
interface KCallable<out R> : KAnnotatedElement
interface KCallable<out R> : KAnnotatedElement

Represents a callable entity, such as a function or a property.

KClass
Link copied to clipboard
interface KClass<T : Any> : KClassifier
interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier
interface KClass<T : Any> : KClassifier
interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier

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.

KClassifier
Link copied to clipboard
Common
interface KClassifier

A classifier is either a class or a type parameter.

Since Kotlin

1.1
KDeclarationContainer
Link copied to clipboard
interface KDeclarationContainer
interface KDeclarationContainer

Represents an entity which may contain declarations of any other entities, such as a class or a package.

KFunction
Link copied to clipboard
interface KFunction<out R> : KCallable<R> , Function<R>
interface KFunction<out R> : KCallable<R> , Function<R>
interface KFunction<out R> : KCallable<R> , Function<R>

Represents a function with introspection capabilities.

Native
interface KFunction<out R> : KCallable<R> , Function<R>
KMutableProperty
Link copied to clipboard
Common
interface KMutableProperty<V> : KProperty<V>

Represents a property declared as a var.

KMutableProperty0
Link copied to clipboard
Common
interface KMutableProperty0<V> : KProperty0<V> , KMutableProperty<V>

Represents a var-property without any kind of receiver.

Native
interface KMutableProperty0<V> : KProperty0<V> , KMutableProperty<V>
KMutableProperty1
Link copied to clipboard
Common
interface KMutableProperty1<T, V> : KProperty1<T, V> , KMutableProperty<V>

Represents a var-property, operations on which take one receiver as a parameter.

Native
interface KMutableProperty1<T, V> : KProperty1<T, V> , KMutableProperty<V>
KMutableProperty2
Link copied to clipboard
Common
interface KMutableProperty2<D, E, V> : KProperty2<D, E, V> , KMutableProperty<V>

Represents a var-property, operations on which take two receivers as parameters.

Native
interface KMutableProperty2<D, E, V> : KProperty2<D, E, V> , KMutableProperty<V>
KParameter
Link copied to clipboard
interface KParameter : KAnnotatedElement

Represents a parameter passed to a function or a property getter/setter, including this and extension receiver parameters.

KProperty
Link copied to clipboard
Common
interface KProperty<out V> : KCallable<V>

Represents a property, such as a named val or var declaration. Instances of this class are obtainable by the :: operator.

KProperty0
Link copied to clipboard
Common
interface KProperty0<out V> : KProperty<V> , Function0<V>

Represents a property without any kind of receiver. Such property is either originally declared in a receiverless context such as a package, or has the receiver bound to it.

Native
interface KProperty0<out V> : KProperty<V> , Function0<V>
KProperty1
Link copied to clipboard
Common
interface KProperty1<T, out V> : KProperty<V> , Function1<T, V>

Represents a property, operations on which take one receiver as a parameter.

Native
interface KProperty1<T, out V> : KProperty<V> , Function1<T, V>
KProperty2
Link copied to clipboard
Common
interface KProperty2<D, E, out V> : KProperty<V> , Function2<D, E, V>

Represents a property, operations on which take two receivers as parameters, such as an extension property declared in a class.

Native
interface KProperty2<D, E, out V> : KProperty<V> , Function2<D, E, V>
KType
Link copied to clipboard
interface KType
interface KType : KAnnotatedElement

Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability.

KTypeParameter
Link copied to clipboard
Common
interface KTypeParameter : KClassifier

Represents a declaration of a type parameter of a class or a callable. See the Kotlin language documentation for more information.

Since Kotlin

1.1
KTypeProjection
Link copied to clipboard
Common
data class KTypeProjection(variance: KVariance?, type: KType?)

Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type Array<out Number>, out Number is the covariant projection of the type represented by the class Number.

Since Kotlin

1.1
KVariance
Link copied to clipboard
Common
enum KVariance : Enum<KVariance>

Represents variance applied to a type parameter on the declaration site (declaration-site variance), or to a type in a projection (use-site variance).

Since Kotlin

1.1
KVisibility
Link copied to clipboard
enum KVisibility : Enum<KVisibility>

Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code. Visibility can be changed with one of the following modifiers: public, protected, internal, private.

Since Kotlin

1.1

Functions

cast
Link copied to clipboard
Common
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
findAssociatedObject
Link copied to clipboard
JS
inline fun <T : Annotation> KClass<*>.findAssociatedObject(): Any?

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

Native
inline fun <T : Annotation> KClass<*>.findAssociatedObject(): Any?

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

safeCast
Link copied to clipboard
Common
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
typeOf
Link copied to clipboard
Common
inline fun <T> typeOf(): KType

Returns a runtime representation of the given reified type T as an instance of KType.

Since Kotlin

1.3

Properties

javaType
Link copied to clipboard
@ExperimentalStdlibApi
val KType.javaType: Type

Returns a Java Type instance corresponding to the given Kotlin type.