Master Advanced Java Debugging: Conditional Breakpoints, Drop Frame, Multi‑Thread & Remote Debugging
This guide walks you through five powerful Java debugging techniques—including conditional breakpoints, dropping frames to revisit previous calls, multi‑thread debugging, remote debugging setup, and on‑the‑fly expression evaluation—to help you debug code more efficiently and confidently.
This article explains five advanced debugging techniques for Java developers.
Conditional breakpoints
Drop Frame (go back one step)
Multi‑thread debugging
Remote debugging
Temporary expression evaluation / variable modification
1. Conditional Breakpoints
When iterating over a large list, you can set a breakpoint that only stops when a specific condition (e.g., i == 10) is met.
Right‑click the red dot next to the breakpoint, choose Condition , and enter the expression.
2. Drop Frame (Go Back "One Step")
This technique is useful when a complex call stack has already passed a breakpoint and you need to inspect earlier variable values without rerunning the program.
Click the Drop Frame icon (red arrow) to revert the execution pointer to the previous stack frame.
After dropping the frame, the method restarts from the beginning and variables reflect their earlier state. This works because the JVM stores each thread's state in stack frames.
3. Multi‑Thread Debugging
When multiple threads run concurrently, breakpoints may jump between threads unpredictably. To control this, set each breakpoint's Suspend policy to Thread instead of All .
After configuring the breakpoints, you can select a specific thread (e.g., "Sky Bird") from the dropdown to have the breakpoint fire only in that thread.
The breakpoint now stops exactly where you expect.
4. Remote Debugging
4.1 Enable Remote Debugging on Startup
java -server -Xms512m -Xmx512m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9081 -Djava.ext.dirs=. ${main_class}The crucial part is the -Xrunjdwp option, which opens a socket for the debugger.
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9081Make sure the port does not conflict with other services and that the local machine can reach the remote host.
4.2 Configure Remote Debugging in IDEA
After setting the remote configuration, you can start debugging.
Place breakpoints in the local source code; when the remote code reaches those points, execution will pause.
5. Evaluate Expressions / Modify Variable Values
During a debugging session you can evaluate arbitrary expressions or change variable values on the fly.
Click the + icon, type an expression such as i+5, and press Enter to see the result.
To change a variable's value, right‑click it, choose Set Value , and enter the new value.
Applying these debugging tricks can make your development workflow smoother and more productive.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
