Package-level declarations

Functions and annotations specific to the Java platform.

Functions and annotations specific to the Java platform.

Functions and annotations specific to the Java platform.

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY])
annotation class JvmDefault

Specifies that a JVM default method should be generated for non-abstract Kotlin interface member.

Since Kotlin 1.2
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class JvmDefaultWithoutCompatibility

Prevents the compiler from generating compatibility accessors for the annotated class or interface, and suppresses any related compatibility warnings. In other words, this annotation makes the compiler generate the annotated class or interface in the -Xjvm-default=all mode, where only JVM default methods are generated, without DefaultImpls.

Since Kotlin 1.4
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
expect annotation class JvmField

Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field.

@Target(allowedTargets = [AnnotationTarget.FIELD])
actual annotation class JvmField

Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
expect annotation class JvmInline

Specifies that given value class is inline class.

Since Kotlin 1.5
@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class JvmInline

Specifies that given value class is inline class.

Since Kotlin 1.5
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FILE])
expect annotation class JvmMultifileClass

Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts. Name of the corresponding multifile class is provided by the JvmName annotation.

@Target(allowedTargets = [AnnotationTarget.FILE])
actual annotation class JvmMultifileClass

Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts. Name of the corresponding multifile class is provided by the JvmName annotation.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
expect annotation class JvmName(val name: String)

Specifies the name for the Java class or method which is generated from this element.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE])
actual annotation class JvmName(val name: String)

Specifies the name for the Java class or method which is generated from this element.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR])
expect annotation class JvmOverloads

Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR])
actual annotation class JvmOverloads

Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
expect annotation class JvmRecord

Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods

Since Kotlin 1.5
@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class JvmRecord

Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods

Since Kotlin 1.5
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
expect annotation class JvmStatic

Specifies that an additional static method needs to be generated from this element if it's a function. If this element is a property, additional static getter/setter methods should be generated.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
actual annotation class JvmStatic

Specifies that an additional static method needs to be generated from this element if it's a function. If this element is a property, additional static getter/setter methods should be generated.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPE])
expect annotation class JvmSuppressWildcards(val suppress: Boolean = true)

Instructs compiler to generate or omit wildcards for type arguments corresponding to parameters with declaration-site variance, for example such as Collection<out T> has.

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPE])
actual annotation class JvmSuppressWildcards(val suppress: Boolean = true)

Instructs compiler to generate or omit wildcards for type arguments corresponding to parameters with declaration-site variance, for example such as Collection<out T> has.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD])
expect annotation class JvmSynthetic

Sets ACC_SYNTHETIC flag on the annotated target in the Java bytecode.

@Target(allowedTargets = [AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD])
actual annotation class JvmSynthetic

Sets ACC_SYNTHETIC flag on the annotated target in the Java bytecode.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.TYPE])
expect annotation class JvmWildcard

Instructs compiler to generate wildcard for annotated type arguments corresponding to parameters with declaration-site variance.

@Target(allowedTargets = [AnnotationTarget.TYPE])
actual annotation class JvmWildcard

Instructs compiler to generate wildcard for annotated type arguments corresponding to parameters with declaration-site variance.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class PurelyImplements(val value: String)
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class PurelyImplements(val value: String)

Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. "Pure" means here that each type parameter of class becomes non-platform type argument of that interface.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS])
expect annotation class Strictfp

Marks the JVM method generated from the annotated function as strictfp, meaning that the precision of floating point operations performed inside the method needs to be restricted in order to achieve better portability.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS])
actual annotation class Strictfp

Marks the JVM method generated from the annotated function as strictfp, meaning that the precision of floating point operations performed inside the method needs to be restricted in order to achieve better portability.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
expect annotation class Synchronized

Marks the JVM method generated from the annotated function as synchronized, meaning that the method will be protected from concurrent execution by multiple threads by the monitor of the instance (or, for static methods, the class) on which the method is defined.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
actual annotation class Synchronized

Marks the JVM method generated from the annotated function as synchronized, meaning that the method will be protected from concurrent execution by multiple threads by the monitor of the instance (or, for static methods, the class) on which the method is defined.

@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
actual annotation class Synchronized
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR])
annotation class Throws(val exceptionClasses: KClass<out Throwable>)
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR])
annotation class Throws(val exceptionClasses: KClass<out Throwable>)

This annotation indicates what exceptions should be declared by a function when compiled to a JVM method.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
expect annotation class Transient

Marks the JVM backing field of the annotated property as transient, meaning that it is not part of the default serialized form of the object.

@Target(allowedTargets = [AnnotationTarget.FIELD])
actual annotation class Transient

Marks the JVM backing field of the annotated property as transient, meaning that it is not part of the default serialized form of the object.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
expect annotation class Volatile

Marks the JVM backing field of the annotated property as volatile, meaning that writes to this field are immediately made visible to other threads.

@Target(allowedTargets = [AnnotationTarget.FIELD])
actual annotation class Volatile

Marks the JVM backing field of the annotated property as volatile, meaning that writes to this field are immediately made visible to other threads.

@Target(allowedTargets = [AnnotationTarget.FIELD])
actual annotation class Volatile

Functions

Link copied to clipboard
fun <T : Any> Array<*>.isArrayOf(): Boolean
fun <T : Any> Array<*>.isArrayOf(): Boolean

Checks if array can contain element of type T.

Properties

Link copied to clipboard

Returns a KClass instance corresponding to the annotation type of this annotation.

Returns a KClass instance corresponding to the annotation type of this annotation.

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.

@get:JvmName(name = "getJavaClass")
val <T> KClass<T>.java: Class<T>

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

Link copied to clipboard
val <T : Any> T.javaClass: Class<T>

Returns the runtime Java class of this object.

val <T : Any> T.javaClass: Class<T>

Returns the runtime Java class of this object.

@get:JvmName(name = "getRuntimeClassOfKClassInstance")
val <T : Any> KClass<T>.javaClass: Class<KClass<T>>
@get:JvmName(name = "getRuntimeClassOfKClassInstance")
val <T : Any> KClass<T>.javaClass: Class<KClass<T>>
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.

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

Link copied to clipboard

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

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

Link copied to clipboard
@get:JvmName(name = "getKotlinClass")
val <T : Any> Class<T>.kotlin: KClass<T>

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

@get:JvmName(name = "getKotlinClass")
val <T : Any> Class<T>.kotlin: KClass<T>

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