Using IntelliJ's 12 Ultimate, I'm running the following code in the Debugger:
Java
import play.api.libs.json.JsValue;
public class Foo {
...
public JsValue toJson() { ... }
public class FooExample {
...
Foo foo = new Foo();
System.out.println("...); //<-- breakpoint
At the breakpoint, I right-clicked my source code and picked "Evaluate Expression," typing in:
foo.toJson()
.
But the following error showed up:
No such instance method: play.api.libs.json.JsValue$class.com.foo.Foo.toJson ()
Am I doing something wrong? Foo#toJson
calls Scala code, if that matters.
EDIT I actually had the breakpoint after the instantiation of Foo.
To those who downvoted it, I deserved it.
EDIT
My answer is no longer valid after OP modified question (i.e. moved where the breakpoint actual is)..
A breakpoint is hit before the line is executed. So in this case foo
has not yet been declared or instantiated (i.e. the Foo
constructor has not yet been called). You'll need to put the breakpoint at the next line (or step over the current line) if you want to evaluate foo
.
I ran into that issue trying to call org.jdbi.v3.core.result.ResultIterable#one
in the Evaluate expression window during a debugging session.
IntelliJ showed the following error message
No such instance method: 'one'
while the code was just running fine when I did not have a debugger attached.
It turned out that my Project language level in IntelliJ was no set properly (can be set under Project settings -> Project).
The one
method is implemented as a default
method in an interface.
My JAVA_HOME
was properly set to a JDK 12 but the Project language level was set to 6.
After adjusting the Project language level to 12 the error was gone and I could step through the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With