Kotlin 1.3.30 released
We’re happy to announce the release of Kotlin 1.3.30, a new bug fix and tooling update for Kotlin 1.3. The main areas of focus for this release have been around Kotlin/Native, KAPT performance, as well as improvements for IntelliJ IDEA.
Incremental annotation processing in KAPT
KAPT now supports incremental annotation processors in an experimental mode. To try it, add the following setting to
Note that in the current implementation, using any non-incremental annotation processor or a change in dependency’s ABI (so far, including modifying internal declarations) will lead to non-incremental annotation processing for a given module.
It’s still work in progress and it’s going to be improved in future releases, but we encourage you to try it now and share your feedback!
KAPT: other performance improvements
Back in 1.2.60, we introduced two options to improve build performance. The first one was using Gradle workers:
and it has been improved with this release.
The second option introduced, this time in 1.3.20, enabled Compile Avoidance, which skips annotation processing if only method bodies are changed in dependencies. Compile Avoidance is possible only when all KAPT dependencies are declared explicitly in annotation processing classpath. To turn off AP discovery in compile path, and therefore turn on Compile Avoidance, add the following option:
We’re considering enabling these options by default in the near future, so we’d love you to try these in your projects and share with us your feedback!
Note that the minimal supported version of Gradle is now 4.1. For Android Gradle Plugin, it’s 3.0.
Standard library: operations for unsigned number arrays
Starting from Kotlin 1.3 you could use unsigned number types in an experimental mode. This release brings support for more operations for unsigned types and arrays of unsigned types that mirror those for regular number types:
Note that you already could use many functional operations like
map for unsigned arrays, because arrays of unsigned numbers implement
Collection<UInt>. But then it was tied with the performance overhead since the extra object was created when
UIntArray is passed as an object of
Collection<UInt>. Now all the added extension functions take exact unsigned array types as receivers, which eliminates this overhead. You can work with an array of unsigned number types like you work with arrays of regular number types without worrying about the underlying performance.
We are happy to announce that the list of supported Kotlin/Native targets has expanded. This release brings support for Windows 32 bit target (mingw_x86). In addition to that, Windows and macOS users can cross-compile their Kotlin/Native programs to Linux x86-64, arm32, as well as Android and Raspberry PI devices.
From the compiler side we added fixes to an undefined behaviour when computing a remainder of a division by 0, which now throws an exception. Alignment related issues were also fixed for ARM32 and MIPS platforms.
Kotlin/Native for Apple platforms
For the Apple platform, we prepared several improvements too. Unhandled exceptions on iOS devices will now be logged to the iOS crash log. Exception backtraces (in debug mode) now contain symbolic information on iOS and macOS.
Static frameworks can be generated too, use the
-Xstatic-framework command line parameter or the following Gradle script for a multiplatform project:
Experimental integration with CocoaPods is added as a dedicated Gradle plugin. It turns a Kotlin/Native project into a
.podfile dependency which can be included into a
Podfile. This allows you to have the same experience when importing and building with Xcode, as you would with Swift or Objective-C pods. We’ve also made it easier to use and import CocoaPods dependencies into Kotlin/Native projects. The plugin does all necessary configuration steps to import a framework into a Kotlin/Native project. Note, that an Xcode project is now required to fetch and build these dependencies.
./gradlew podspec it generates a
.podspec file which can be included into the
Podfile file. For importing a pod, you can use the
We now support returning structures from callback functions, meaning that
staticCFunction now supports
CValue<T> return types! For example, you can call a C function, passing a C function pointer to a Kotlin-implemented function that returns struct:
In addition to that, the following changes were made:
booltype is now correctly mapped
- UTF-32 C-strings are mapped into Kotlin
- C compiler intrinsics are included into the
- libffi library is no longer used
- Clang modules are supported for Objective-C interop
- C interop definition files (
.def) are supported in the IDE
Kotlin/Native IDE support
We are happy to announce the results of our ongoing work to support Kotlin/Native in our IDEs.
In addition to IntelliJ IDEA, we will offer a Kotlin/Native plugin for CLion 2019.1, as well as AppCode 2019.1. C interop definition files (
.def) will also be supported by all IDEs, albeit we do not currently provide code completion.
For CLion and AppCode, we’ve also added navigation from backtraces to source code as well as improvements in the debugger support.
IntelliJ IDEA support
We’re working hard on making debugging coroutines easier. When you debug coroutine code, you now see a separate “Async stack trace” showing the variables stored at the time of suspension. Let’s look at a small example:
When stopping on a breakpoint inside a suspend function or lambda (in this example, at line 13), “Async stack trace” additionally shows you the state of the variables at the last point of suspension (line 12). You can browse the whole stacktrace of suspend functions starting from the last suspension point in the current coroutine (lines 12 and 4) and check the stored values of the variables:
It should help you understand how you got to the current point of execution.
While debugging Kotlin code, you can now choose “Kotlin” mode to observe the values of the variables. After clicking on the Kotlin icon, you see the variables by Kotlin names, not by auxiliary JVM names, as before:
<img class=”alignnone size-full wp-image-4043″ src=”//blog.jetbrains.com/kotlin/files/2019/04/variables-mode-frame.png” onmouseover=”this.src=’//blog.jetbrains.com/kotlin/files/2019/03/variables-mode.gif’;”
onmouseout=”this.src=’//blog.jetbrains.com/kotlin/files/2019/04/variables-mode-frame.png’;” alt=”” width=”700″ />
Note that you can always add missing variables by using watches, and either merge “variables” and “watches” windows as in the screenshot above or keep them separate, as you prefer.
Interactive mode for scratch files
As you know, in Kotlin you can perform small experiments with your codebase using scratch files. Now you can use interactive mode which shows you the results on the fly (after a given timeout), without the need to explicitly rerun the script:
<img class=”alignnone size-full wp-image-4043″ src=”//blog.jetbrains.com/kotlin/files/2019/04/scratches.png” onmouseover=”this.src=’//blog.jetbrains.com/kotlin/files/2019/03/scratches.gif’;”
onmouseout=”this.src=’//blog.jetbrains.com/kotlin/files/2019/04/scratches.png’;” alt=”” width=”700″ />
Do you check from time to time TODO items list in your project? IntelliJ IDEA now correctly highlights multiline TODO comments and displays them in the list:
Some useful inspections and quickfixes were added in this release, such as a fix to automatically introduce an import alias for the imported class name, or a warning of using ‘forEach’ method from Java 8 interface rather than from the Kotlin standard library.
Eclipse IDE plugin update
New 0.8.14 release of the plugin for the Eclipse IDE brings: support for the Kotlin 1.3.30 compiler, numerous bugfixes and improvements in overall stability. This update also introduces experimental support for Gradle projects. You can now import your projects with Eclipse Buildship and then you can find them in your Eclipse workspace with correct Kotlin plugin configuration.
You can install experimental Gradle integration via the update site:
https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/last/. To do so open
Install new software dialog from Eclipse’s help menu. Then enter update site url and select
New Gradle integration works in Spring Tool Suite as well. You are no longer forced to use Maven when you want to develop a Spring application in Kotlin.
Specifying JVM bytecode targets 9 – 12
If you run the code under JVM versions 9, 10, 11, or 12, you can now set the corresponding
jvmTarget. This setting will affect the version of the generated classfiles, and the resulting bytecode won’t run on any lower version of JVM. Note that so far newer versions don’t add any bytecode optimizations or features beyond the ones that exist in lower versions, but that is going to change in the future.
How to update
As always, you can try Kotlin online at play.kotl.in.
- In Maven, Gradle and npm: Use
1.3.30as the version number for the compiler and the standard library. See the docs here.
- In IntelliJ IDEA and Android Studio: Update the Kotlin plugin to version 1.3.30. Use Tools | Kotlin | Configure Kotlin Plugin Updates and click the “Check for updates now” button.
- In Eclipse: Install the plugin using Marketplace.
- The command-line compiler can be downloaded from the Github release page.
We’re especially grateful to our colleagues from Google for the work on supporting incremental compilation in KAPT!
We also thank our community contributors for this release; we appreciate your work. In particular:
- Toshiaki Kameyama
- Mads Ager
- Ivan Gavrilovic
- Ting-Yuan Huang
- Dereck Bridie
- kenji tomita
- Bernhard Posselt
- Burak Eregar
- Marcin Moskala
- Felix Guo
- Tor Norbye
- Yaroslav Ulanovych
- Pavel Nikitin
- Mark Punzalan
- Kevin Peek
- Jim S
- Timo Obereder
Subscribe to Blog updates
Thanks, we've got you!
Kotlin 1.9.20 Released
Kotlin 1.9.20 has been released! Highlights include: Kotlin K2 for all targets is in Beta, and Kotlin Multiplatform is Stable. Learn more!
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…