在 kotlin 中使用 imgui 端口工作时,我有一个 metrics
菜单,在其中显示分配数量
这是init code我写道:
try {
var ac: AttachingConnector? = null
for (x in Bootstrap.virtualMachineManager().attachingConnectors()) {
if (x.javaClass.name.toLowerCase().indexOf("socket") != -1) {
ac = x
break
}
}
if (ac == null) {
throw Error("No socket attaching connector found")
}
val connectArgs = HashMap<String, Argument>(ac.defaultArguments())
connectArgs["hostname"]!!.setValue("127.0.0.1")
connectArgs["port"]!!.setValue(Integer.toString(3001))
connectArgs["timeout"]!!.setValue("3000")
vm = ac.attach(connectArgs)
} catch (error: Exception) {
System.err.println("Couldn't retrieve the number of allocations, $error")
}
这些是我作为“VM 选项”传入的参数
-Xdebug -Xrunjdwp:transport=dt_socket,address=3001,server=y,suspend=n
只要我正常运行它,它就可以工作。但如果我在 Debug模式下运行它,它不会,返回以下错误:
java.net.ConnectException: Connection refused: connect
我还找不到解决方案,目前我只是显示 -1
来指示错误
有人有解决方案/解释吗?
规范:
- Kotlin 1.2-m1
- 想法2017.2.1
最佳答案
我猜问题是您尝试为调试器使用与程序使用的端口相同的端口。尝试为调试器使用不同的端口。
关于java - 在 Debug模式下计算实例化类的数量失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45509344/