Kotlin M1 Candidate

IntelliJ IDEA 11.1 has been recently released, and we are happy to announce a milestone candidate build for Kotlin IDE plugin, too. This post gives an overview of what happened over the last month.

Milestone Candidate Build is Ready for Your Evaluation

To install on IntelliJ IDEA 11.1 (Free Community Edition is available here), please follow the instructions from the Getting Started guide. In short:

You can always download nightly builds of Kotlin from our build server or build it yourself from sources.

Now we proceed to a short overview of the New and Noteworthy. Please refer to this blog post for the previously implemented features.

Little Things that Matter

First of all, we did very many bugfixes, improvements and other important things that are hard to demo. See the commit history on github and the closed issues in YouTrack.


With the power of extension functions, Kotlin makes existing Java APIs better. In particular, we provide enhancements for JDK collections so that you can say things like this:

fun main(args : Array<String>) {
    val list = arrayList(1, 2, 3)
    val odds = list.filter {it % 2 == 1}
    println(odds.join(", "))

Here, filter() and join() are extension functions.

Implementation-wise, extension functions are just static utility functions, like “good old” Java’s Collecions.*, but with the “receiver.function()” call syntax, the IDE makes them much better: there is code completion that helps you browse through the API and learn it (just as if the extensions were normal class members):

You can navigate to sources of library functions:

And see the doc comments there:

The HTML version of the library docs is available here.

GitHub Support

Kotlin highlighting is now supported by github, including gist.


Kotlin now supports annotations. Here’s a small example that relies on JUnit 4:

import org.junit.Test as test
import org.junit.Assert.*

class Tests {
    test fun simple() {
        assertEquals(42, getTheAnswer())

Read more here.

String Templates

Now you can use multi-line string templates, for example:

  First name: $first
  Last name: $last
  Age: $age

Simple Enums

Simple cases of enum classes are now supported. For example:

enum class Color {

Local Functions

Functions can be declared inside other functions:

fun count() : Int {
  fun count(parent : Entity) : Int {
    return 1 + parent.children.sum { count(it) }
  return count(this.root)


Kotlin now recognizes the @Nullable and @NotNull annotations). If the Java code says:

@NotNull String foo() {...}

Kotlin will trat foo() as returning a non-nullable String.

A short-hand operator (!!) for converting a nullable value into a non-nullable one is added:

val foo = getSomethingThatMayBeNull()
foo!!.bar() // throw NPE if foo is null, run bar() otherwise

Byte Code Unveiled

Click on the Kotlin button on the right edge of the IDEA window, and choose the “Bytecode” tab. You’ll see the byte-code Kotlin generates for your program!

Your feedback is very welcome. Have a nice Kotlin!

Comments below can no longer be edited.

15 Responses to Kotlin M1 Candidate

  1. Avatar

    Loic says:

    March 30, 2012

    Thanks for this great work!

  2. Avatar says:

    March 30, 2012

    Failed to load descriptor. 🙁 (Mac Lion)

    • Avatar

      Andrey Breslav says:

      March 30, 2012

      If ti’s from plugin manager, please re-try, or download the zip. We’ll try to fix this.

  3. Avatar says:

    March 30, 2012

    Resolved now 😀

  4. Avatar

    Charles Oliver Nutter says:

    March 31, 2012

    If foo!!.bar() raises NPE if foo is null, how exactly does that differ from simply calling

    • Avatar

      Nikolay Krasko says:

      March 31, 2012

      After !!. operator was added to Kotlin program there’s no difference in behavior from call in Java. But the great difference was at previous step when compiler was able to find a place with probable NPE threat and asked programmer to resolve it explicitly.

      You can find more information about null-safety feature in Kotlin on this wiki page.

      • Avatar

        Justin Lee says:

        March 31, 2012

        So if I read that correctly, without !!, the compiler will fail on a possible null reference. But the !! tells the compiler to butt out and let it fail at runtime?

        • Avatar

          Nikolay Krasko says:

          April 2, 2012

          Yes you’re right. And this is the reason why !! calls should be used with great caution or avoided completely. If you are in Kotlin and not planning to assign null value to variable just declare it with not-nullable type. While working with methods and variables from Java it’s better to choose some safe way to deal with possible null value. It can be ?. call or pre-check to null.

    • Avatar

      Andrey Breslav says:

      April 8, 2012

      Hey Charles,

      Glad to see you here!

  5. Avatar

    Alex Yakunin says:

    April 2, 2012

    Guys, what you do is awesome!

    Personally I’d switch to Kotlin right after first RC.

    • Avatar

      Andrey Breslav says:

      April 8, 2012

      Thanks for the encouraging words!

  6. Avatar

    Sergii Rudchenko says:

    April 12, 2012

    Thank you guys, this is a brilliant work!
    I’ll switch to Kotlin as soon as it gets Android support.

    Also Kotlin has inspired me to switch to IntelliJ IDEA 🙂
    Keep up the good work!

  7. Avatar

    Guangyu says:

    May 1, 2012

    How to use JUnit with kotlin? or how to have unit test with kotlin? Can you provide any example on it ?

    I found compile speed will become very very slow, and KCompile will report the following error:

    java.lang.IllegalStateException: Internal error: (14,72) java.lang.AssertionError
    at org.jetbrains.jet.codegen.CompilationErrorHandler$1.reportException(
    at org.jetbrains.jet.codegen.GenerationState.compileCorrectFiles(
    at org.jetbrains.jet.compiler.CompileSession.generate(
    at org.jetbrains.jet.compiler.CompileEnvironment.compileModule(
    ... 89 more

    even for the following code:

    package hhh.csp

    import org.apache.log4j.Logger
    import org.apache.log4j.PropertyConfigurator
    import org.junit.*
    import org.junit.rules.ExpectedException
    import junit.framework.TestCase
    import junit.framework.TestSuite

    public class IntervalTest(name :String) : TestCase(name) {

    fun testIntervalPlus() {
    val values : Array = Array(10000,{});
    var v:Interval =;
    for( i in values ) i.u = 1.0;
    for ( i in values) v = v+i;