Reputation: 528
I am adding Kotlin native linuxX64 target support to some existing library. Library is compiled successfuly but while running the test cases, I am getting following runtime error:
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.Array@1249428
at kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception (0x271205)
at kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException (0x2711c5)
at kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException (0x272595)
at ThrowInvalidMutabilityException (0x3b0b53)
at (0x3b5733)
Even the Object example given in Kotlin language tutorial is not working on giving the similar runtime exception.
I know the problem is due to the frozen objects. But I could not find the proper way to modify the frozen members of singleton object.
Upvotes: 3
Views: 731
Reputation: 528
After searching a bit I got the answer. We can update the frozen object using the Atomic Reference.
Upvotes: 3