JvmExposeBoxed

This annotation instructs the compiler to expose the API of functions with inline classes (and the classes containing them, including inline classes themselves) as their boxed variant for effective usage from Java.

It performs the following transformations:

  • For annotated functions and constructors that take or return inline classes, an unmangled wrapper function is created where inline classes are boxed. The wrapper is thus visible and callable from Java.

  • If class is annotated, the annotation implicitly propagates to its methods, forcing the compiler to generate wrappers for them.

  • A constructor is made available from Java.

These changes maintain backward compatibility, allowing existing API to be safely marked.

Since Kotlin

2.2

This annotation instructs the compiler to expose the API of functions with inline classes (and the classes containing them, including inline classes themselves) as their boxed variant for effective usage from Java.

It performs the following transformations:

  • For annotated functions and constructors that take or return inline classes, an unmangled wrapper function is created where inline classes are boxed. The wrapper is thus visible and callable from Java.

  • If class is annotated, the annotation implicitly propagates to its methods, forcing the compiler to generate wrappers for them.

  • A constructor is made available from Java.

These changes maintain backward compatibility, allowing existing API to be safely marked.

Since Kotlin

2.2

Properties

Link copied to clipboard
expect val jvmName: String

optional wrapper name. Only applicable to functions, getters and setters.

Since Kotlin 2.2
actual val jvmName: String

optional wrapper name. Only applicable to functions, getters and setters.

Since Kotlin 2.2