Kotlin logo

Kotlin

A concise multiplatform language developed by JetBrains

Releases

Kotlin 1.5.0 – the First Big Release of 2021

Read this post in other languages:

Welcome the first feature release in accordance with the new release scheduleKotlin 1.5.0!

This release delivers stable language features such as JVM records, sealed interfaces, inline classes, and includes the new default JVM IR compiler. Your feedback on the feature previews in Kotlin 1.4.30 and Kotlin 1.5.0 EAP releases have really helped us to stabilize these features.
We’re very grateful for your assistance! Thank you!

More than 25,000 developers have already tried the new JVM IR compiler in IntelliJ IDEA.

You will notice the benefits over time. The new compiler shares a unified pipeline and business logic with Kotlin/Native and Kotlin/JS IR compilers, which will allow us to implement most features, optimizations, and bug fixes for all platforms simultaneously. It will also allow you to add custom processing and transformations that will automatically work on all platforms.

Do you have questions about Kotlin 1.5.0? Roman Elizarov, Svetlana Isakova, and other members of the Kotlin team will be available to answer your questions live on May 25 during the Kotlin 1.5 Online Event.

Register for the Event


In this blog post, you will find an overview of:

Auto-update to Kotlin 1.5.0

If you are using IntelliJ IDEA or Android Studio, it 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.0.

Stable language features

Kotlin 1.5.0 includes stable versions of the new language features presented for preview in 1.4.30:

  • Support for JVM records to remain interoperable with the latest Java features – record classes.
    To use a Kotlin class as a record in Java code, make it a data class and mark it with the @JvmRecord annotation:

    Learn more about requirements for using JVM records.

  • Sealed interfaces. The sealed modifier works on interfaces the same way it works on classes – all implementations of a sealed interface are known at compile time.
  • Sealed class improvements. Previously, all subclasses had to be in the same file with sealed classes. Now they can be in all files of the same compilation unit and the same package.
  • Inline classes are a subset of value-based classes that only hold values. You can use them as wrappers for a value of a certain type without the additional overhead that comes from using memory allocations. Use the value modifier for the declaration.

Learn more about Kotlin 1.5.0 language features

Standard and test library improvements

The New stable APIs for unsigned integer types are the most anticipated Kotlin 1.5.0 library improvements based on the survey we conducted in the Kotlin 1.5.0-RC blog post.

The standard library provides many helpful features, including:

  • The new stable APIs for unsigned integer types as well as for ranges, progressions, and functions for them. Learn more about unsigned integers.
  • Extension functions for java.nio.file.Path to use the modern non-blocking Java IO in a Kotlin-idiomatic style.
  • String and Char API improvements including the new locale-agnostic API for changing the case of strings and characters, a set of new functions for conversion between characters and their integer codes and numeric values, and multiplatform support for more char functions.
  • Duration API changes including using a Long value for the internal representation and providing new properties for retrieving a duration as a Long value.

The test library comes with a set of important improvements:

  • Single kotlin-test dependency in the common source set of multiplatform projects.
  • Automatic choice of a testing framework for Kotlin/JVM source sets when you specify only the kotlin-test dependency.
  • A number of assertion function updates.

Learn more about library improvements

Kotlin/JVM

Kotlin 1.5.0 brings:

Kotlin/Native

Kotlin 1.5.0 provides:

  • Support for compiler caches in debug mode for linuxX64 and iosArm64 targets. With compiler caches enabled, most debug compilations complete much faster, except for the first one. Measurements showed about a 200% speed increase on our test projects.
  • Deactivation of the built-in memory leak checker to avoid issues that may cause application crashes. Learn how to activate the memory leak checker if you need it.

Kotlin/JS

Kotlin/JS moves towards promoting the new Kotlin/JS IR compiler to Beta. Many well-known frameworks and libraries are already available for the IR compiler: KVision, fritz2, doodle, and others.

If you’re a library author, you can add your library to these by migrating your library using the backwards compatibility.

Another additional improvement is building JS bundles using webpack 5 instead of webpack 4.

How to install Kotlin 1.5.0

If you already use IntelliJ IDEA or Android Studio, it will suggest updating Kotlin to 1.5.0 automatically once the release is out. You can also update it manually by following these instructions. Note that only Android Studio 4.2.0, Arctic Fox Canary 15, and later versions support Kotlin 1.5.0.

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 the Kotlin version 1.5.0 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

Kotlin 1.5 Online Event

Join the Kotlin 1.5 Online Event on May 25, where the Kotlin team will answer all your questions about the latest release. You can ask about anything you’d like to know, or if you don’t have any questions and are just interested in the answers, that is great too. The event will last for 1.5 hours.

Post your questions on Twitter with #kotlin15ask or add your questions in the registration form.

Register for the Event

We will also conduct an Ask Me Anything (AMA) session on Reddit on May 27-28 to address any questions left unanswered as well as answer any new ones too.

Compatibility

As with all feature releases, some deprecation cycles of previously announced changes are coming to an end with Kotlin 1.5.0. All of these cases were carefully reviewed by the language committee and are listed in the Compatibility Guide for Kotlin 1.5. You can also explore these changes on YouTrack.

Watch and read more

Watch Kotlin YouTube:

Read the Kotlin blog:

Learn more from the Kotlin docs:

External contributors

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

Jinseong Jeon, Mads Ager, Ivan Gavrilovic, pyos, Steven Schäfer, Iaroslav Postovalov, scaventz, Kristoffer Andersen, Bingran, Stefan Wolf, Victor Turansky, fjjohnchen, justin.wei, Nelson Osacky, Mikhail Galanin, Michael Hoisie, Kris Hall, Kevin Bierhoff, Jiaxiang Chen, Hung Nguyen, Cedric Champeau.

Top issue reporters from YouTrack

We’d like to thank 👏👏👏 all the members of the community who have helped us make this release better by reporting issues to YouTrack! We’ve made a list of the top 20 reporters and would like to thank them specifically:

Morgan Bartholomew (118 issues); Marc Knaup (78 issues); Ryan Nett (61 issues); Louis CAD (48 issues); Daniil Stepanov (44 issues); AndroidDeveloperLB (39 issues); Victor Turansky (38 issues); Jinseong Jeon (35 issues); Zac Sweers (25 issues); Łukasz Wasylkowski (22 issues); Tianyi Guan (21 issues); Christoph Sturm (20 issues); Axel Fontaine (19 issues); Alexander Nozik (18 issues); Robert Stoll (18 issues); Björn Kautler (18 issues); Róbert Papp (14 issues); Andreas Malik (14 issues); Lorenzo Neumann (14 issues);
Iaroslav Postovalov (14 issues).


Install Kotlin 1.5.0 and register for the Kotlin 1.5 Online Event!

image description