Kotlin
A concise multiplatform language developed by JetBrains
Kotlin 1.5.0 – the First Big Release of 2021
Welcome the first feature release in accordance with the new release schedule – Kotlin 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.
In this blog post, you will find an overview of:
- Stable language features – JVM records, sealed interfaces, and inline classes.
- Standard and test library improvements, including stable unsigned integer types, extensions for
java.nio.file.Path
, as well as String, Char, and Duration API improvements. - Kotlin/JVM improvements, including the new default JVM IR compiler.
- Kotlin/Native improvements, including faster debug compilation for Linux and iOS applications.
- Kotlin/JS improvements, including migration of more JS libraries to the new Kotlin/JS IR compiler.
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 adata
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
- Read the language feature preview blog post.
- Read the language documentation.
- Watch the language video series.
Standard and test library improvements
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 aLong
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
- Read the library improvement blog post with examples.
- Read the What’s new in Kotlin 1.5.0.
- Watch the video.
Kotlin/JVM
Kotlin 1.5.0 brings:
- The new JVM IR compiler, announced in Kotlin 1.4.0, becomes Stable and default. Learn more about the new compiler in the blog post and docs.
- Compilation of SAM adapters and lambdas into dynamic invocations (invokedynamic), which benefits from the latest JVM features. Compilation of Kotlin plain lambdas is Experimental.
- New default JVM target: 1.8. The
1.6
target is deprecated. - Improved handling of type nullability information from Java.
- Deprecation of @JvmDefault and old Xjvm-default modes.
Kotlin/Native
Kotlin 1.5.0 provides:
- Support for compiler caches in debug mode for
linuxX64
andiosArm64
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
- Find help on Slack (get an invite).
- Report issues to our issue tracker, YouTrack.
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.
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:
- Kotlin 1.5.0 video playlist
- Subscribe to Kotlin YouTube to avoid missing videos about new improvements in coroutines and serialization libraries.
Read the Kotlin blog:
- Kotlin 1.5.0 language features preview
- Kotlin 1.5.0 standard and test library improvements
- New JVM IR backend
- Improved IDE support for Kotlin in IntelliJ IDEA
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!