May 5, 2021

Kotlin 1.5 available with JVM records, sealed interfaces, and more

Kotlin 1.5 available with JVM records, sealed interfaces, and more

Kotlin 1.5 available with JVM records, sealed interfaces, and more

The first major Kotlin release of 2021 is now here. Kotlin 1.5 adds JVM records, sealed interfaces, inline classes, and the new JVM IR compiler. 

JVM records are classes that carry a fixed set of values. Kotlin developers can now use a Kotlin class as a record in Java by making it a data class and marking it with the @JvmRecord annotation. 

Sealed interfaces provide more control over inheritance. According to Kotlin’s documentation, once a module containing a sealed interface is compiled, no new implementations of it can appear.

Inline classes are a subset of value-based classes. They only hold values and can be used as wrappers for values of a certain type, thus preventing additional overhead associated with using memory allocations. 

Kotlin 1.5 also introduces several updates to the standard library, such as new stable APIs for unsigned integer types, extension functions, String and Char API improvements, and duration API changes. 

New features added to the test library include single kotlin-test dependency in the common source set of multiplatform projects, automatic choice of a testing framework for source sets, and assertion function updates.

More information can be found in the Kotlin 1.5 release notes.