views:

202

answers:

2

Is it possible to skip a statement in Eclipse while debugging? Suppose the process stopped at breakpoint and I want to skip the breakpoint line ( or maybe a few lines below), can I do it? On the debug tab, it only has "Step into", "Step over" and "Step return" buttons.

I did google around but couldn't find anything, hopefully I can find an answer here.

+1  A: 

If you are debugging, you can comment out the line you want to skip and then recompile, which will hotswap the code and keep you within the method you are currently in, allowing you to skip the line.

Depending on what you want to have happen, you could simply execute the line after the one you want to skip, select the code and choose Display from the r-click menu. This will execute the selected code and provide the result in a popup.

akf
A: 

You can set breakpoint conditions that will determine whether or not this breakpoint will stop or will continue on. I don't know of any way for you to tell it to skip the next few line without changing the code to something like:

if ( skip ) {
  // contents to be skipped 
}

and then at the breakpoint set skip to true.

For the breakpoint conditions, if you return true will stop and return false will continue. In here you can actually execute code and do whatever you want (including setting the value of skip).

nevets1219
though this is a way to do it, it needs some extra work to compile the source code and add the classes to classpath.
You do not need to add anything to the classpath. Everything you have available in the code is available in the breakpoint conditions. Perhaps Eclipse does something behind the scenes but neither of us will have to worry about that. Also as far as I know I can change the breakpoint condition during execution without incurring a full rebuild.
nevets1219
in my case, the WLS server is running with the jar file I'm trying to debug. And Eclipse is attached to a debug port of the server, if I change the source code, it will be out of sync with runtime jar file. I've tried this, it didn't work.
I don't know of any method to "skip" lines of codes and I want to say it's not possible but I don't know that for sure.
nevets1219