Create breakpoint when a specific method is called

Viewed 456

I'm working on a Java legacy code (in Eclipse). It works fine (its output is correct); however, it prints an extra blank line. I want to find this statement and remove it, but there are lots of System.out.print lines in the code and I cannot check them one by one. Is there any way to ask the Eclipse debugger to pause when System.out.print is called? It's similar to putting breakpoints on every System.out.print in the code (and the debugger will stop when it reaches these lines).

4 Answers

I think just set breakpoint on System.out#print method should work fine.
jdk source code:

public void println(String x) {
    synchronized (this) {
        print(x);  // break point here
        newLine();
    }
}

I don't think that's possible. But to tackle your problem, you can see the System.out.println statement above the blank line and add a breakpoint there.

This way you'll be able to get to the line faster.

Can't you search in the code the line value? I mean, something like ctrl + f -> system.out.println(" ') //or whatever it prints. And then comment all the resulting lines.

I know that maybe it's lame, but sometimes the solution is simplier than it looks.

I think you have to use conditional breakpoint. You can check this and this might also help.

Related