【问题标题】:-Dkotlinx.coroutines.debug not working in IntelliJ IDEA JVM options-Dkotlinx.coroutines.debug 在 IntelliJ IDEA JVM 选项中不起作用
【发布时间】:2018-08-28 02:12:10
【问题描述】:

我正在使用 Mac OS 上的 IntelliJ IDEA 尝试使用 official guide 的 Kotlin 协程。在this 部分,建议使用-Dkotlinx.coroutines.debug JVM 选项来获取详细的日志输出。我所做的是我打开了“帮助/编辑自定义 VM 选项...”并在打开的 idea.vmoptions 文件中添加了-Dkotlinx.coroutines.debug 行。

idea.vmoptions编辑后的内容:

    # 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

但是再次运行代码后,输出是:

[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

而预期的输出是:

[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

我在这里错过了什么?

【问题讨论】:

    标签: intellij-idea kotlin kotlinx.coroutines


    【解决方案1】:

    Help > Edit custom VM options... 菜单选项可让您设置用于执行 IntelliJ itself 的 VM 选项。

    要为您自己的应用程序设置选项,您需要编辑运行/调试配置。这些可以在菜单的 Run > Edit Configurations... 下找到。

    选择此选项会打开以下窗口,让您可以为应用程序设置 VM 选项:

    【讨论】:

    • 小心,“=”后没有多余的空间……确实像“-Dkotlinx.coroutines.debug=on”
    猜你喜欢
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 2016-01-07
    • 2011-06-30
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多