how are fields and variables evaluated at breakpoints

Answered

Hi ,

When the debugger pauses at a breakpoint, it shows the values for all the variables and fields that are in scope. I'm curious to know how the class field values are derived. I have the following snippet of code that I'm debugging and all 3 variables are fields of the current class. My breakpoint is on `curVal = formatVal()` line. When the execution stopped at breakpoint, I see `prevVal` is `null`, but after I hit F8 and move to next line, my `prevVal` is changing. My `formatVal()` method doesn't do any assignment to `prevVal`, so, how is this value getting evaluated? There is a different method in my class that assigns value to `prevVal`, but that is not hit at the time of this execution.

```
void initializeVars() {
         prevVal = null ;
         curVal = formatVal();
         someboolean = false;
}
```

0
2 comments

If you have toString evaluation enabled for the debugger, it can cause side effects when debugging, try disabling this option: https://intellij-support.jetbrains.com/hc/articles/206544799.

0
Avatar
Permanently deleted user

That helped. Thank you Serge.

0

Please sign in to leave a comment.