How do I display variables in Scala methods while calling them from Java program in Eclipse debugger? I am debugging a Java program which calls methods in Scala libraries. I can put breakpoints there and the break-point works. But the debugger is unable to display the variables. I am using Eclipse.
-
1Are you using Scala-IDE plugin in Eclipse? It seems to me that Java debugger can only understand bytecode and thus breakpoints work, but it can't reconstruct AST and does not know how to display those otherwise. Maybe it needs to be pointed to source code location? I might be wrong.yǝsʞǝla– yǝsʞǝla2014-01-29 04:00:23 +00:00Commented Jan 29, 2014 at 4:00
-
I am not using Scala-IDE plugin. I am using a Java program that calls method in the ApacheKafka library and that is in Scala. I have the source attached, I mean it is pointing to correct source location.Nipun Talukdar– Nipun Talukdar2014-01-29 04:33:06 +00:00Commented Jan 29, 2014 at 4:33
2 Answers
Well, it's gonna be quite non-trivial if you don't install the Scala plugin for Eclipse, you can find it here:
Scala is compiled for the JVM so you will be able to debug it without the plugin. Theoretically. The practical issue is that the class file contains tons of generated stuff which can be extremely hard to understand (even for guys who're pro how Scala translates its concepts, e.g., anonymous functions into bytecode).
Just an example: you'll have to deal with monsters like scala.some.Class$$anon$1$$anonfun$someFunction$1$2$$anonfun$apply$2.apply. It is far-far easier if you install the plugin and see something like c -> c.somefunction( println(e)).
So try to find out which version of Scala was used for your dependency, install the required Scala IDE for that Scala version, attach the source and you'll be able to debug.
4 Comments
Make sure you use the scala-ide
See here the support for debugging Scala projects and how to set it up: http://scala-ide.org/docs/current-user-doc/features/scaladebugger/index.html