Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get IntelliJ to show unused variables in debugger

Sometimes when debugging I put an extra variable in the code so I can then see the value of that variable in the debugger. However it seems that if the extra variable is not used anywhere else in the code then IntelliJ does not include the variable in the debugger. I've gotten around this by declaring a dummy variable and setting it equal to the variable I want to see in the debugger, because that way IntelliJ sees that the extra variable is used.

Is there a way to configure IntelliJ to show unused variables in the debugger?

like image 510
Thomas Avatar asked Mar 23 '23 11:03

Thomas


1 Answers

Since the Java compiler is what removes the unused variables, the solution I found was to configure the Java compiler used by IntelliJ to not remove unused variables.

Specifically in my case I use the Eclipse compiler in IntelliJ, so all I had to do was configure the compiler with the additional command line parameter:

-preserveAllLocals
like image 118
Thomas Avatar answered Apr 05 '23 23:04

Thomas