scalacenter / scala-debug-adapter

Implementation of the Debug Adapter Protocol for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hot code replace restarting on top of method

iusildra opened this issue · comments

With this code

@main def Test =
  println("ok")

Hot reloading with

@main def Test =
  val x = 1
  println("ok")

Makes the debugger resume at val x = 1 instead of println("ok")

I don't know if it's the expected behavior or a bug

Also, on Dotty if I change the body of Applications#resolveOverloaded1 it resumes at the definition of the method and not in its body. Also bis, local variables do not seem to be cleaned as I still have one that I deleted with a hot reload. They must be cached somewhere

I don't know if it's the expected behavior or a bug

That's not a bug, it is a limitation of the JVM.

With this code:

@main def Test =
  println("ok")

Hot reloaded with:

@main def Test =
  val x = 1
  x + 1

Where is it supposed to stop?

Also, on Dotty if I change the body of Applications#resolveOverloaded1 it resumes at the definition of the method and not in its body.

Not sure about this case specifically. But in general the JVM must unstack all previous frames of a reloaded class.
Suppose I have this stack frame:

A.a2
B.b
A.a1
Main.main

After I reload A I will have:

A.a1
Main.main

I cannot be in A.a2 anymore, I not even sure if A.a2 will be called.

Also bis, local variables do not seem to be cleaned as I still have one that I deleted with a hot reload. They must be cached somewhere

Do you have a specific example about this? Can you open another issue with more details?