#Debugging Scala with JDB
It seems impossible to find answers on how to debug Scala with jdb on Google. I wanted to consolidate what I've learned in a easy to digest guide. Please feel free to comment with other tips I may have missed, or corrections to what's here.
##Classes
Setting a breakpoint in a class is just like debugging java
stop at my.package.ClassName:22
or
stop in my.package.ClassName.methodName
##Objects
Setting a breakpoint in an object is usually just as simple as adding a $
to
the end of the object/package name.
stop at my.package.ObjectName$:22
##Traits
In general break in the implementing class. However, if there's a default
implementation that you're trying to break in use the trait path with the
suffix $.class
for example
stop in my.package.SomeTrait$.class.foo
would set a breakpoint in the default implementation of foo
in the Trait
SomeTrait
FYI, while it's still early in development, there's a Scala-oriented version of jdb, called sdb, found here: https://scala-debugger.org/
Github page here: https://github.com/ensime/scala-debugger
Disclaimer is that I'm the maintainer of it, but thought I'd spread the word a little bit for those seeking something like it.
Gave a talk at ScalaSphere about the debugging tooling and whatnot. Can be found here.