Annotation

Common
JVM
JS
Native
1.0
interface Annotation
(Common source) (Native source)

Base interface implicitly implemented by all annotation interfaces. See Kotlin language documentation for more information on annotations.

Extension Properties

JVM
1.0

annotationClass

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

val <T : Annotation> T.annotationClass: KClass<out T>

Inheritors

JS
Native
1.1

AssociatedObjectKey

Makes the annotated annotation class an associated object key.

annotation class AssociatedObjectKey
Native
1.3

BetaInteropApi

Marks Objective-C and Swift interoperability API as Beta.

annotation class BetaInteropApi
Common
JVM
JS
Native
1.3

BuilderInference

Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function.

annotation class BuilderInference
Native
1.3

CCall

annotation class CCall
Native
1.3

CEnumEntryAlias

Denotes property that is an alias to some enum entry.

annotation class CEnumEntryAlias
Native
1.3

CEnumVarTypeSize

Stores instance size of the type T: CEnumVar.

annotation class CEnumVarTypeSize
Common
Native
1.3

CName

Makes top level function available from C/C++ code with the given name.

annotation class CName
Common
JVM
JS
Native
1.7

ContextFunctionTypeParams

Signifies that the annotated functional type has the prefix of size count for context receivers. Thus, @ContextFunctionTypeParams(2) @ExtensionFunctionType Function4<String, Int, Double, Byte, Unit> is a normalized representation of context(String, Int) Double.(Byte) -> Unit.

annotation class ContextFunctionTypeParams
Native
1.3

CStruct

annotation class CStruct
Common
JVM
JS
Native
1.0

Deprecated

Marks the annotated declaration as deprecated.

annotation class Deprecated
Common
JVM
JS
Native
1.4

DeprecatedSinceKotlin

Marks the annotated declaration as deprecated. In contrast to Deprecated, severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the -api-version argument when compiling the module where the usage is located). If the API version is greater or equal than hiddenSince, the declaration will not be accessible from the code (as if it was deprecated with level DeprecationLevel.HIDDEN), otherwise if the API version is greater or equal than errorSince, the usage will be marked as an error (as with DeprecationLevel.ERROR), otherwise if the API version is greater or equal than warningSince, the usage will be marked as a warning (as with DeprecationLevel.WARNING), otherwise the annotation is ignored.

annotation class DeprecatedSinceKotlin
Common
JVM
JS
Native
1.1

DslMarker

When applied to annotation class X specifies that X defines a DSL language

annotation class DslMarker
JS
1.6

EagerInitialization

Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property.

annotation class EagerInitialization
Native
1.3

EagerInitialization

Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default".

annotation class EagerInitialization
JS
Native
1.1

ExperimentalAssociatedObjects

The experimental marker for associated objects API.

annotation class ExperimentalAssociatedObjects
Common
JVM
JS
Native
1.3

ExperimentalContracts

This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions.

annotation class ExperimentalContracts
Common
JVM
JS
Native
1.8

ExperimentalEncodingApi

This annotation marks the experimental API for encoding and decoding between binary data and printable ASCII character sequences.

annotation class ExperimentalEncodingApi
Native
1.3

ExperimentalForeignApi

Marks foreign-language-related API as experimental.

annotation class ExperimentalForeignApi
Common
JVM
JS
Native
1.4

ExperimentalJsExport

Marks experimental JS export annotations.

annotation class ExperimentalJsExport
Common
JVM
JS
Native
1.9

ExperimentalJsFileName

Marks experimental JsFileName annotation.

annotation class ExperimentalJsFileName
Common
JVM
JS
Native
1.9

ExperimentalJsReflectionCreateInstance

This annotation marks the experimental Kotlin/JS reflection API that allows to create an instance of provided KClass The API can be removed completely in any further release.

annotation class ExperimentalJsReflectionCreateInstance
Common
JVM
JS
Native
1.0

ExperimentalMultiplatform

The experimental multiplatform support API marker.

annotation class ExperimentalMultiplatform
Common
JVM
JS
Native
1.9

ExperimentalNativeApi

This annotation marks the Kotlin/Native-only standard library API that is considered experimental and is not subject to the general compatibility guarantees given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release.

annotation class ExperimentalNativeApi
Common
JVM
JS
Native
1.8

ExperimentalObjCName

This annotation marks the experimental ObjCName annotation.

annotation class ExperimentalObjCName
Common
JVM
JS
Native
1.8

ExperimentalObjCRefinement

This annotation marks the experimental Objective-C export refinement annotations.

annotation class ExperimentalObjCRefinement
JVM
JRE7
1.4

ExperimentalPathApi

This annotation marks the extensions and top-level functions for working with java.nio.file.Path considered experimental.

annotation class ExperimentalPathApi
JVM
1.5

ExperimentalReflectionOnLambdas

This annotation marks the experimental kotlin-reflect API that allows to approximate a Kotlin lambda or a function expression instance to a KFunction instance. The behavior of this API may be changed or the API may be removed completely in any further release.

annotation class ExperimentalReflectionOnLambdas
Common
JVM
JS
Native
1.3

ExperimentalStdlibApi

This annotation marks the standard library API that is considered experimental and is not subject to the general compatibility guarantees given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release.

annotation class ExperimentalStdlibApi
Common
JVM
JS
Native
1.8

ExperimentalSubclassOptIn

This annotation marks the experimental preview of the language feature SubclassOptInRequired.

annotation class ExperimentalSubclassOptIn
Common
JVM
JS
Native
1.3

ExperimentalTime

This annotation marks the experimental preview of the standard library API for measuring time and working with durations.

annotation class ExperimentalTime
Common
JVM
JS
Native
1.3

ExperimentalTypeInference

The experimental marker for type inference augmenting annotations.

annotation class ExperimentalTypeInference
Common
JVM
JS
Native
1.0

ExperimentalUnsignedTypes

Marks the API that is dependent on the experimental unsigned types, including those types themselves.

annotation class ExperimentalUnsignedTypes
Native
1.3

ExportObjCClass

Makes Kotlin subclass of Objective-C class visible for runtime lookup after Kotlin main function gets invoked.

annotation class ExportObjCClass
Common
JVM
JS
Native
1.0

ExtensionFunctionType

Signifies that the annotated functional type represents an extension function.

annotation class ExtensionFunctionType
Native
1.3

ExternalObjCClass

annotation class ExternalObjCClass
Common
Native
1.7

FreezingIsDeprecated

Freezing API is deprecated since 1.7.20.

annotation class FreezingIsDeprecated
Common
Native
1.8

HiddenFromObjC

Instructs the Kotlin compiler to remove this class, function or property from the public Objective-C API.

annotation class HiddenFromObjC
Common
Native
1.8

HidesFromObjC

Meta-annotation that instructs the Kotlin compiler to remove the annotated class, function or property from the public Objective-C API.

annotation class HidesFromObjC
Common
JS
1.8

Ignore

annotation class Ignore
Common
JVM
1.9

ImplicitlyActualizedByJvmDeclaration

This annotation marks Kotlin expect declarations that are implicitly actualized by Java.

annotation class ImplicitlyActualizedByJvmDeclaration
Native
1.3

InteropStubs

annotation class InteropStubs
Common
JS
1.3

JsExport

Exports top-level declaration on JS platform.

annotation class JsExport
JS
1.9

JsExternalArgument

When placed on a function parameter, requires the type of the passed argument to be external.

annotation class JsExternalArgument
JS
1.9

JsExternalInheritorsOnly

When placed on an external interface or class, requires all its child interfaces, classes, and objects to be external as well.

annotation class JsExternalInheritorsOnly
Common
JS
1.9

JsFileName

Specifies the name of the compiled file produced from the annotated source file instead of the default one.

annotation class JsFileName
JS
1.1

JsModule

Denotes an external declaration that must be imported from native JavaScript library.

annotation class JsModule
Common
JS
1.0

JsName

Gives a declaration (a function, a property or a class) specific name in JavaScript.

annotation class JsName
JS
1.1

JsNonModule

Denotes an external declaration that can be used without module system.

annotation class JsNonModule
JS
1.1

JsQualifier

Adds prefix to external declarations in a source file.

annotation class JsQualifier
JVM
1.2

JvmDefault

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

annotation class JvmDefault
JVM
1.6

JvmDefaultWithCompatibility

Forces the compiler to generate compatibility accessors for the annotated interface in the DefaultImpls class. Please note that if an interface is annotated with this annotation for binary compatibility, public derived Kotlin interfaces should also be annotated with it, because their DefaultImpls methods will be used to access implementations from the DefaultImpls class of the original interface.

annotation class JvmDefaultWithCompatibility
JVM
1.4

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.

annotation class JvmDefaultWithoutCompatibility
Common
JVM
1.0

JvmField

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

annotation class JvmField
Common
JVM
1.5

JvmInline

Specifies that given value class is inline class.

annotation class JvmInline
Common
JVM
1.0

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.

annotation class JvmMultifileClass
Common
JVM
1.0

JvmName

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

annotation class JvmName
Common
JVM
1.0

JvmOverloads

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

annotation class JvmOverloads
Common
JVM
1.5

JvmRecord

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

annotation class JvmRecord
Common
JVM
1.8

JvmSerializableLambda

Makes the annotated lambda function implement java.io.Serializable, generates a pretty toString implementation and adds reflection metadata.

annotation class JvmSerializableLambda
Common
JVM
1.0

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.

annotation class JvmStatic
Common
JVM
1.0

JvmSuppressWildcards

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.

annotation class JvmSuppressWildcards
Common
JVM
1.0

JvmSynthetic

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

annotation class JvmSynthetic
Common
JVM
1.0

JvmWildcard

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

annotation class JvmWildcard
JVM
1.3

Metadata

This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size.

annotation class Metadata
Common
JVM
JS
Native
1.0

MustBeDocumented

This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied.

annotation class MustBeDocumented
JS
1.1

nativeGetter

annotation class nativeGetter
JS
1.1

nativeInvoke

annotation class nativeInvoke
Native
1.9

NativeRuntimeApi

This annotation marks the Kotlin/Native standard library API that tweaks or otherwise accesses the Kotlin runtime behavior.

annotation class NativeRuntimeApi
JS
1.1

nativeSetter

annotation class nativeSetter
Native
1.3

ObjCAction

Makes Kotlin method in Objective-C class accessible through Objective-C dispatch to be used as action sent by control in UIKit or AppKit.

annotation class ObjCAction
Native
1.3

ObjCConstructor

annotation class ObjCConstructor
Native
1.3

ObjCDirect

annotation class ObjCDirect
Native
1.3

ObjCFactory

annotation class ObjCFactory
Native
1.3

ObjCMethod

annotation class ObjCMethod
Common
Native
1.8

ObjCName

Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function.

annotation class ObjCName
Native
1.3

ObjCOutlet

Makes Kotlin property in Objective-C class settable through Objective-C dispatch to be used as IB outlet.

annotation class ObjCOutlet
Native
1.9

ObsoleteNativeApi

This annotation marks the Kotlin/Native standard library API that is considered obsolete and is being phased out.

annotation class ObsoleteNativeApi
Native
1.9

ObsoleteWorkersApi

Marks all Worker-related API as obsolete.

annotation class ObsoleteWorkersApi
Common
JVM
JS
Native
1.3

OptIn

Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with OptIn, its usages are not required to opt in to that API.

annotation class OptIn
Common
JVM
JS
Native
1.0

OptionalExpectation

Marks an expected annotation class that it isn't required to have actual counterparts in all platforms.

annotation class OptionalExpectation
Common
JVM
JS
Native
1.4

OverloadResolutionByLambdaReturnType

Enables overload selection based on the type of the value returned from lambda argument.

annotation class OverloadResolutionByLambdaReturnType
Common
JVM
JS
Native
1.1

ParameterName

Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any).

annotation class ParameterName
Common
JVM
JS
Native
1.1

PublishedApi

When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public.

annotation class PublishedApi
JVM
1.0

PurelyImplements

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.

annotation class PurelyImplements
Common
Native
1.8

RefinesInSwift

Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as swift_private in the generated Objective-C API.

annotation class RefinesInSwift
Common
JVM
JS
Native
1.0

Repeatable

This meta-annotation determines that an annotation is applicable twice or more on a single code element

annotation class Repeatable
Common
JVM
JS
Native
1.0

ReplaceWith

Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation.

annotation class ReplaceWith
Common
JVM
JS
Native
1.3

RequiresOptIn

Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in.

annotation class RequiresOptIn
Common
JVM
JS
Native
1.3

RestrictsSuspension

Classes and interfaces marked with this annotation are restricted when used as receivers for extension suspend functions. These suspend extensions can only invoke other member or extension suspend functions on this particular receiver and are restricted from calling arbitrary suspension functions.

annotation class RestrictsSuspension
Common
JVM
JS
Native
1.0

Retention

This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true.

annotation class Retention
Common
Native
1.0

SharedImmutable

Note: this annotation has effect only in Kotlin/Native with legacy memory manager.

annotation class SharedImmutable
Common
Native
1.8

ShouldRefineInSwift

Instructs the Kotlin compiler to mark this function or property as swift_private in the generated Objective-C API.

annotation class ShouldRefineInSwift
Common
JVM
JS
Native
1.0

SinceKotlin

Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the -api-version command line option) will result in an error.

annotation class SinceKotlin
Common
JVM
1.0

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.

annotation class Strictfp
Common
JVM
JS
Native
1.8

SubclassOptInRequired

Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in.

annotation class SubclassOptInRequired
Common
JVM
JS
Native
1.0

Suppress

Suppresses the given compilation warnings in the annotated element.

annotation class Suppress
Native
1.3

SymbolName

This is a dangerous deprecated and internal annotation. Please avoid using it.

annotation class SymbolName

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.

Common
JS
1.0
annotation class Synchronized
JVM
1.0
annotation class Synchronized
Common
JVM
JS
Native
1.0

Target

This meta-annotation indicates the kinds of code elements which are possible targets of an annotation.

annotation class Target
Common
Native
1.0

ThreadLocal

Marks a top level property with a backing field or an object as thread local. The object remains mutable and it is possible to change its state, but every thread will have a distinct copy of this object, so changes in one thread are not reflected in another.

annotation class ThreadLocal

Throws

This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native.

Common
Native
1.4
annotation class Throws
JVM
1.4
typealias Throws = Throws
JVM
1.0

Throws

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

annotation class Throws
Common
JVM
1.0

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.

annotation class Transient
Native
1.3

UnsafeNumber

Marker for declarations that depend on numeric types of different bit width on at least two platforms.

annotation class UnsafeNumber
Common
JVM
JS
Native
1.0

UnsafeVariance

Suppresses errors about variance conflict

annotation class UnsafeVariance

Volatile

Marks the JVM backing field of the annotated var property as volatile, meaning that reads and writes to this field are atomic and writes are always made visible to other threads. If another thread reads the value of this field (e.g. through its accessor), it sees not only that value, but all side effects that led to writing that value.

Common
JS
1.0
annotation class Volatile
JVM
1.0
annotation class Volatile

Volatile

Marks the backing field of the annotated var property as volatile, meaning that reads and writes to this field are atomic and writes are always made visible to other threads. If another thread reads the value of this field (e.g. through its accessor), it sees not only that value, but all side effects that led to writing that value.

Common
Native
1.9
annotation class Volatile
JVM
1.9
typealias Volatile = Volatile