You are currently viewing The JVM Backend Is in Beta: Let’s Make It Stable Together

The JVM Backend Is in Beta: Let’s Make It Stable Together

We’ll make the new backend Stable soon, so we need each of you to adopt it, let’s see how to do it.

We have been working to implement a new JVM IR backend as part of our ongoing project to rewrite the whole compiler. This new compiler will boost performance both for Kotlin users and for the Kotlin team itself by providing a versatile infrastructure that makes it easy to add new language features.

Our work on the JVM IR backend is nearly complete, and we’ll be making it Stable soon. Before we can do that, though, we need you to use it. In Kotlin 1.4.30, we’re making the new backend produce stable binaries, which means you will be able to safely use it in your projects. Read on to learn about the changes this new backend brings, as well as how to contribute to the process of finalizing this part of the compiler.

What changes with the new backend:

  • We’ve fixed a number of bugs that were present in the old backend.
  • The development of new language features will be much faster.
  • We will add all future performance improvements to the new JVM backend.
  • The new Jetpack Compose will only work with the new backend.

Another point in favor of starting to use the new JVM IR backend now is that it will become the default in Kotlin 1.5.0. Before we make it the default, we want to make sure we fix as many bugs as we can, and by adopting the new backend early you will help ensure that the migration is as smooth as possible.

To start using the new JVM IR backend

  1. Update the Kotlin dependency to 1.4.30 in your project.
  2. In the build configuration file, add the following lines to the target platform block of your project/module to turn the new compiler on.
    For Gradle add the following:

    • In Groovy
      compileKotlin {
          kotlinOptions.useIR = true
    • In Kotlin
          import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
          // ...
          val compileKotlin: KotlinCompile by tasks
          compileKotlin.kotlinOptions.useIR = true

    And for Maven add the following:

  3. Please make a clean build and run tests after enabling the new backend to verify that your project compiles successfully.

You shouldn’t notice any difference, but if you do, please report it in YouTrack or send us a message in this Slack channel (get an invite here). When you do, please attach a list of steps to reproduce the problem and a code sample if possible.

You can switch back to the old backend anytime simply by removing the line from step two and rebuilding the project.