小编Eng*_*ler的帖子

为什么 Intellij 的调试器会在此 Scala 代码中两次命中断点

对于以下 scala 代码,当我在 if 语句处设置调试点并启用“日志:断点命中消息”时

object App1 {
  def main(args: Array[String]): Unit = {
    iftest()
  }
  def iftest(): Unit = {
    val setA: Set[String] = Set("a", "b", "c");
    var setB: Set[String] = Set("d", "e", "f")
    if(setA.size > setB.size){ //here break point at line 8
      println("bigger")
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我在控制台中得到以下输出。问题是为什么这个断点会被击中两次?

Breakpoint reached at com.eguller.App1$.iftest(App1.scala:8)
Breakpoint reached at com.eguller.App1$.iftest(App1.scala:8)
Run Code Online (Sandbox Code Playgroud)

但对于以下类似的 Java 代码,断点仅被命中一次。

Breakpoint reached at com.eguller.App1$.iftest(App1.scala:8)
Breakpoint reached at com.eguller.App1$.iftest(App1.scala:8)
Run Code Online (Sandbox Code Playgroud)

我得到以下输出

Breakpoint reached at com.eguller.JApp.main(JApp.java:8)
Run Code Online (Sandbox Code Playgroud)

这是 Intellij 调试器中的错误,还是 Scala 编程语言的功能?

IntelliJ IDEA …

java debugging scala breakpoints intellij-idea

5
推荐指数
1
解决办法
319
查看次数

标签 统计

breakpoints ×1

debugging ×1

intellij-idea ×1

java ×1

scala ×1