Kotlin 1.5.30-RC With Java Toolchains in Gradle, JS IR Backend in Beta, Stdlib Improvements, and More
The 1.5.30 release is approaching, and now we’re presenting the release candidate with the updated opt-in requirements, Kotlin/JS IR backend in Beta, support for Java toolchains in the Gradle plugin, improvements to the Regex and Duration API in the standard library, and more. Try it and report any issues you face to help us prepare the final release.
We’ve unveiled the first set of Kotlin 1.5.30 features with the 1.5.30-M1 preview. In this post, we’ll briefly describe some more of the new features that you can try with Kotlin 1.5.30-RC:
- Updated opt-in requirement mechanism, more consistent and less error-prone
- Experimental instantiation of annotation classes
- Kotlin/JS IR backend is promoted to Beta and ready for migration
- Support for Java toolchains in the Gradle plugin
- Improvements to the Regex and Duration API
Kotlin’s opt-in requirement mechanism has been available in the Experimental state for quite some time, and releasing it as Stable is on our roadmap. In 1.5.30, we’re changing the behavior of the opt-in requirements to make it more consistent and less error-prone:
- An opt-in is now required for implicit usages of the marked API, for example, if it’s used as a function’s return type.
- Opt-in annotations are now prohibited on more declarations, including local variables, value parameters, backing fields, and getters.
- Overriding methods can only have opt-in annotations that are present on their basic declarations.
- Opt-in annotations can’t have
Instantiation of annotation classes
The ability to create instances of annotation classes by calling their constructors is another improvement on the Kotlin roadmap. In 1.5.30-RC, we’re adding the opt-in support for this ability to the JVM.
To allow creation of annotation instances with constructors, switch to the language version
1.6 by adding the
-language-version 1.6 compiler option. You can find more details about this feature in this KEEP.
JS IR backend in Beta
The IR-based backend for the Kotlin/JS compiler has been in Alpha since Kotlin 1.4.0. We never stopped working on it, and in 1.5.30 it will become Beta. This means that we don’t expect breaking changes anymore and its future development will be mainly focused on stabilization.
How to migrate
- Read the migration guide
- Install the Kotlin/JS Inspection Pack IDE plugin that partially automates the migration
- Report migration issues to our issue tracker, YouTrack.
Gradle: Java toolchain support and JVM options for Kotlin daemon in the build script
Gradle 6.7 introduced the support for Java toolchains – an easy way to select a JDK for the project compilation. Just declare the version you need in the build script, and Gradle does the rest, finding it on your host or even downloading and installing it if it’s not there yet.
Kotlin 1.5.30-RC enables Java toolchain support for Kotlin compilation tasks:
Other Gradle-related improvements include new ways to provide JVM options for the Kotlin Gradle daemon. Now you can specify them in a separate line in
Regex and Duration API improvements
Kotlin’s Regex API is receiving new experimental functions:
matchesAt()checks if a regex has a match in the specified position of a String. It’s accompanied by
matchAt()that returns the match itself if it is found.
splitToSequence()– a lazy counterpart of
split()– splits the string around matches of the given regex, but returns the result as a
Sequence. A similar function is also added to
The experimental Duration API has also been updated in 1.5.30-RC:
- The output of
Duration.toString()has become more readable. For example,
Duration.minutes(2415).toString()produces 1d 16h 15m instead of 40.3h.
- Duration also receives new functions for parsing from strings:
Try the new features and report issues
All Kotlin 1.5.30 features (including those presented in the 1.5.30-M1 preview) are available in the release candidate 1.5.30-RC. You can easily install it in your IDE – IntelliJ IDEA or Android Studio – in any of these ways:
- If you use the Early Access Preview update channel, the IDE will suggest updating to 1.5.30-RC automatically once it is out.
- If you use the Stable update channel, you can change the channel to Early Access Preview at any time by selecting Tools | Kotlin | Configure Kotlin Plugin Updates in your IDE, then you’ll be able to install the latest preview release. Check out these instructions for details.
You can always download the latest versions of these IDEs to get extensive support for Kotlin:
- IntelliJ IDEA for developing Kotlin applications for a variety of platforms.
- Android Studio for developing Android and cross-platform mobile applications.
Note: the latest version of IntelliJ IDEA – 2021.2 – doesn’t support Kotlin 1.5.30 previews. If you have already upgraded to this version, you can easily install the previous version (2021.1) using the JetBrains Toolbox App and try Kotlin 1.5.30-RC in that version.
Once you’ve installed 1.5.30-RC, change the Kotlin version to
1.5.30-RC in your build scripts.
If you run into any problems:
- Report issues to our issue tracker, YouTrack.
- Find help in the #eap channel in Kotlin Slack (get an invite).
- Roll back to the latest stable version. Learn how.
- Preview of Kotlin 1.5.30 With Native Apple Silicon Support, Improved Kotlin DSL for the CocoaPods Gradle Plugin, and More
- Participate in the Early Access Preview
Subscribe to Blog updates
Thanks, we've got you!
Kotlin 1.9.0 Released
Kotlin 1.9.0 has been released! Highlights include: Kotlin K2 for JVM is in Beta, other K2 compiler updates, new enum class values function, new operator for open-ended ranges, preview of Gradle configuration cache in Kotlin Multiplatform, changes for Android target support in Kotlin Multiplatform, preview of custom memory allocator in Kotlin/Native. Learn more!
Introducing Kotlin Notebook
The first experimental version of the Kotlin Notebook plugin for IntelliJ IDEA is now available! This post will offer insight into the plugin’s functionality and use cases, but before launching into that, we’d like to let the plugin speak for itself: https://youtu.be/2PLYlDJPelQ W…
Kotlin 1.8.20 Released
Kotlin 1.8.20 has been released! Highlights include: Kotlin K2 compiler updates, AutoCloseable interface and Base64 encoding in stdlib, new JVM incremental compilation enabled by default, new Kotlin/Wasm compiler backend. Learn more!