I'm trying Kotlin's coroutines with official guide using IntelliJ IDEA on Mac OS. In this section there's an advice to use -Dkotlinx.coroutines.debug
JVM option to get detailed log output. What I did is I opened 'Help/Edit custom VM options...' and in the opened idea.vmoptions file I added -Dkotlinx.coroutines.debug
line.
idea.vmoptions content after edit:
# custom IntelliJ IDEA VM options
-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Xverify:none
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-Dkotlinx.coroutines.debug
But after running the code again the output is:
[main] I'm computing a piece of the answer
[main] I'm computing another piece of the answer
[main] The answer is 42
Process finished with exit code 0
Whereas expected output is:
[main @coroutine#2] I'm computing a piece of the answer
[main @coroutine#3] I'm computing another piece of the answer
[main @coroutine#1] The answer is 42
What am I missing here?
The Help > Edit custom VM options... menu option lets you set the VM options for the execution of IntelliJ itself.
To set the options for your own application, you need to edit the Run/Debug Configurations. These can be found under Run > Edit Configurations... in the menu.
Selecting this option opens the following window which lets you set the VM options for your application(s):