Static initializer bug



fun main(args: Array<String>) {


class A{
  class object{
  val a: Int
  a = 0

It compiles but throws

Exception in thread “main” java.lang.NoSuchFieldError: a
  at net.unitcraft.content.A.<clinit>(Main.kt:19)
  at net.unitcraft.content.ContentPackage-Main-c1ee52f.main(Main.kt:11)
  at net.unitcraft.content.ContentPackage.main(Main.kt:1)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(
  at java.lang.reflect.Method.invoke(
  at com.intellij.rt.execution.application.AppMain.main(

I use Idea 138.1503.3.


Your version of Kotlin would be of much use to us. Thanks


I dont understand your answer. My english is poor. This bug already fixed in another version of Kotlin? Or this is not bug?


Please reply with your version of Kotlin plugin. You can find it in Preferences, in Plugins section, find Kotlin, version is right below the Uninstall button.


Kotlin plugin


This bug affects only class object fields that initialized in anonymous initializer. As a temporary workaround move field intializer directly to field:

class A{
    class object{
        val a: Int = 0


This bug is already in our tracker (KT-4206), thank you.