2

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.

http://www.quora.com/How-do-I-display-variables-in-Scala-methods-while-calling-them-from-Java-program-in-Eclipse-debugger

2
  • 1
    Are 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. Commented 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. Commented Jan 29, 2014 at 4:33

2 Answers 2

2

Well, it's gonna be quite non-trivial if you don't install the Scala plugin for Eclipse, you can find it here:

http://scala-ide.org

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I am now using eclipse Scala IDE. I can inspect the member variables etc now. But I cannot inspect the local variables. The IDE pops up a Java.lang.NullPointerException. I am debugging it as a Java application. May be the IDE is confused with the type of the variables.
Which version of the IDE are you using? The guys usually tend to use the latest stable nightly versions. Try asking around the mailing list about the issue: groups.google.com/forum/#!forum/scala-ide-user
I am using Scala IDE 3.0.0 (Eclipse SDK, Version: 3.7.2)
@NipunTalukdar, were you able to resolve this? I can reproduce the NullPointerException on my Eclipse Luna 4.4.2 + scala-ide 4.3.0 v2 which is the latest.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.