Kotlin 1.5.20 Released!

Kotlin continues to stay up to date with latest Java features such as dynamic invocations and to provide better interoperability with Java by adding support for Java’s Lombok and JSpecify. We are also continuing our work of making the standard library consistent across platforms, as well as investing in Gradle tooling and the new JS IR backend.

Update to Kotlin 1.5.20

This blog post provides an overview of the updates in this release:

Auto-update to Kotlin 1.5.20

If you use IntelliJ IDEA or Android Studio, your IDE will give you the option to automatically update to the new Kotlin release as soon as it becomes available.

Learn more about installing Kotlin 1.5.20.

Kotlin/JVM

To benefit from the latest JVM features, Kotlin has extended the use of dynamic invocations (invokedynamic). Kotlin 1.5.0 brought default support for compilation of SAM adapters, while keeping similar features for string concatenation and lambdas Experimental. Kotlin 1.5.20 makes compilation string concatenation to dynamic invocations the default as well.

To maintain the best interoperability with Java, Kotlin 1.5.20 brings experimental support for:

  • Calling Java’s Lombok-generated methods within the same module. The experimental Lombok compiler plugin allows using Java’s Lombok-generated declarations in mixed Kotlin/Java sources. Lombok annotations work only in Java sources and are ignored if you use them in Kotlin code.
    Supported annotations include @With, @Data, @Getter, @Setter, @NoArgsConstructor, @RequiredArgsConstructor, and @AllArgsConstructor.
  • JSpecify project, which includes a standard unified set of Java nullness annotations. This allows you to provide more detailed nullability information to help Kotlin maintain null safety when interoperating with Java. You can set default nullability for the declaration, package, or module scope, specify parametric nullability, and more. 
    Please note that the JSpecify project is under active development. Its API and implementation can change significantly at any time.

Here is an example of how Kotlin can handle JSpecify annotations:

// JavaClass.java
import org.jspecify.nullness.*;

@NullMarked
public class JavaClass {
    public String notNullableString() { return ""; }
    public @Nullable String nullableString() { return ""; }
}
// Test.kt
fun kotlinFun() = with(JavaClass()) {
  notNullableString().length // OK
  nullableString().length    // Warning: receiver nullability mismatch
}

Kotlin/Native

The Kotlin/Native compiler can now export documentation comments (KDoc) from Kotlin code to Objective-C frameworks. This will make these comments visible to the framework’s consumers. This support also works for Swift, and it is Experimental

Another improvement concerns the Array.copyInto() operation inside one array. It now works up to 20 times faster (depending on the number of objects being copied) due to memory management optimization for this case.

Kotlin/JS

Kotlin 1.5.0 has already delivered the new Stable JVM IR backend, so the only missing piece of the new Kotlin IR backend is the Stable JS part. We’re continuing our work to make the Kotlin/JS IR backend Stable, and your feedback would really help us.

An easy way to migrate to the new JS backend is to follow our new migration guide. The guide describes the changes you’ll need to make in your Kotlin/JS code to make it work with the new IR compiler. If you encounter any issues, please report them to our issue tracker, YouTrack.

Gradle

Kotlin 1.5.20 delivers a couple of tooling improvements:

Standard library

Kotlin 1.5.20 continues to provide a similar experience on all platforms for standard library Char features:

  • isLowerCase()/isUpperCase() now provides the same result on all platforms by checking all characters, not only letters.
  • digitToInt() now supports all Unicode digit characters for all platforms – Kotlin/JVM, Kotlin/Native, and Kotlin/JS. Previously, it provided full support only for Kotlin/JVM.

Stay up to date with information about the latest Kotlin features! Enter your email address and subscribe to Kotlin updates using the form to the right of the post.

How to install Kotlin 1.5.20

If you already use IntelliJ IDEA or Android Studio, your IDE will suggest updating Kotlin to 1.5.20 automatically. You can also update it manually by following these instructions

You can always download the latest versions of these IDEs to get extensive support for Kotlin:

  • IntelliJ IDEA for developing Kotlin applications for different platforms.
  • Android Studio for developing Android and cross-platform mobile applications.

Make sure that you have also updated the kotlinx libraries to compatible versions and specified version 1.5.20 of Kotlin in the build scripts of your existing projects.

If you need the command-line compiler, download it from the Github release page.

If you run into any problems

Read and watch more

External contributors 👏👏👏

We’d like to thank all of our external contributors whose pull requests were included in this release:

Alexey Stepanov, Jinseong Jeon, Tianyu Geng, Mark Punzalan, pyos, Mike Sinkovsky, Aleksey Kladov, Mads Sig Ager, Steven Schäfer, Ting-Yuan Huang, Victor Turansky, scaventz, Stefan M, Carlos Ballesteros Velasco, StefMa, Mattia Iavarone, Florian Kistner, Julius Kunze, Sergey Rubanov, Matthew Gharrity, enbandari, Campbell Jones, Br0mm, Kevin Galligan, yantimirov-timur, Ben Asher, Julia, Jared Woolston, Federico Tomassetti, Jens Klingenberg, Nicola Corti, vldf, Dominic Fischer, Martin Petrov, Renee Vandervelde, Robert Hencke, Rodrigo B. de Oliveira, Jeffrey McNally-Dawes, Scott Pierce, Sebsatian Keller, James Wald, Hyojae Kim, hungvietnguyen, Him188, Henrik Tunedal, AJ Alt, Giuseppe Barbieri, Francis Lavoie, Dico Karssiens, Dave Leeds, Thiago Henrique Hüpner, Thomas Vos, Daniel, Collin Monahan, Toshiaki Kameyama, Tristan Greeno, Vanessa Pyne, Charlie Jiang, Cedric Champeau, Boris Pristupa, Bingran, youta ogino, Aydar Mukhametzyanov, Ying Li, Zac Sweers, zadorotskas, ebukreev, kdnakt, 0xflotus, Abhishek Sudhakaran, Marcin Aman, Marcin Kraszewski, Matt Chowning, luca992, Lucas Diego, Louis CAD, Michael Blackman, Michael Hoisie, Lidonis Calhau, LanderlYoung, Kyle Kauffman, Miquel Beltran, Mohit Jayanti Gurumukhani, Muhammad Hakim Asy’ari, Márton Braun, Nekoyue, Nick Apperley, toxicbakery, KotlinIsland, Kjell Winblad, Kevin Waldock, Nils Kunze, Noah, Nwokocha wisdom maduabuchi, Paul Idstein, Keegan Witt, Jonas Seibert, Jiaming Lu


Update to Kotlin 1.5.20