class Test { init { // launch background thread that processes messages from a queue which quickly calls [callback] // gets Null Pointer Exception on state even though intellij says that the null check is not needed. // if state is moved above the init block all is well. } val state = ArrayList() fun callback(data: Int) { state[0] = data // Null Pointer on state, hasn't been initialized yet. } }