For some reason my code stops between those 2 prin...
# getting-started
c
For some reason my code stops between those 2 printlns. It prints
init start
and after a few seconds, displays
Test running process exited unexpectedly.
Any idea what might it be? str is String used is MutableSet<String>
c
Are you running in multiple threads, or with coroutines? Can you post more code?
c
Nope—everything is synchronous—I'm not using coroutines or any library other than the standard one and Kotlin tests. It's running on Kotlin/Native on Windows. It's basically an init block in a class.
str: String
is a parameter,
used: MutableSet<String>
is a property in companion object, declared as:
Copy code
private val used: MutableSet<String> = mutableSetOf()
image.png
image.png
c
What's running the code? A main() function, a test runner?
c
A test (using kotlin.test package)
a
Sounds like there should be some other error output around “exited unexpectedly”
c
It's basically calling a function that creates an instance with a random string
a
e.g. a StackOverflowError or something
c
If you make a main() function that calls just that class, and run that, does the behaviour occur?
c
I can't really do it on the current setup — it's a multiplatform library project
c
You said it’s in a companion object and running in Kotlin/Native? I think that’s your problem,
objects
are frozen on creation, so you can’t modify the collection without the runtime throwing immutability exceptions
c
There's no immutability exception in the logs, though
s
might recommend xposting to #kotlin-native for visibility at this point
c
I will, thanks
d
Hmm, did you initialise
used
before or after
init
?
Oh wait, the
init
is for the class and not the companion object.
c
Yeah, just the
val used
is in the companion object