W3cubDocs

/Kotlin

Package kotlin.reflect.jvm

Runtime API for interoperability between Kotlin reflection and Java reflection provided by kotlin-reflect library.

Extensions for External Classes

Platform and version requirements: JVM (1.0)

java.lang.reflect.Constructor

Platform and version requirements: JVM (1.0)

java.lang.reflect.Field

Platform and version requirements: JVM (1.0)

java.lang.reflect.Method

Properties

Platform and version requirements: JVM (1.0)

isAccessible

Provides a way to suppress JVM access checks for a callable.

var KCallable<*>.isAccessible: Boolean
Platform and version requirements: JVM (1.0)

javaConstructor

Returns a Java Constructor instance corresponding to the given Kotlin function, or null if this function is not a constructor or cannot be represented by a Java Constructor.

val <T> KFunction<T>.javaConstructor: Constructor<T>?
Platform and version requirements: JVM (1.0)

javaField

Returns a Java Field instance corresponding to the backing field of the given property, or null if the property has no backing field.

val KProperty<*>.javaField: Field?
Platform and version requirements: JVM (1.0)

javaGetter

Returns a Java Method instance corresponding to the getter of the given property, or null if the property has no getter, for example in case of a simple private val in a class.

val KProperty<*>.javaGetter: Method?
Platform and version requirements: JVM (1.0)

javaMethod

Returns a Java Method instance corresponding to the given Kotlin function, or null if this function is a constructor or cannot be represented by a Java Method.

val KFunction<*>.javaMethod: Method?
Platform and version requirements: JVM (1.0)

javaSetter

Returns a Java Method instance corresponding to the setter of the given mutable property, or null if the property has no setter, for example in case of a simple private var in a class.

val KMutableProperty<*>.javaSetter: Method?
Platform and version requirements: JVM (1.0)

javaType

Returns a Java Type instance corresponding to the given Kotlin type. Note that one Kotlin type may correspond to different JVM types depending on where it appears. For example, Unit corresponds to the JVM class Unit when it's the type of a parameter, or to void when it's the return type of a function.

val KType.javaType: Type
Platform and version requirements: JVM (1.1)

jvmErasure

Returns the KClass instance representing the runtime class to which this type is erased to on JVM.

val KType.jvmErasure: KClass<*>
Platform and version requirements: JVM (1.0)

jvmName

Returns the JVM name of the class represented by this KClass instance.

val KClass<*>.jvmName: String

Functions

Platform and version requirements: JVM (1.0)

reflect

This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a KFunction instance providing introspection capabilities for that lambda or function expression and its parameters. Not all features are currently supported, in particular KCallable.call and KCallable.callBy will fail at the moment.

fun <R> Function<R>.reflect(): KFunction<R>?

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.jvm/index.html