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).
Asked
Active
Viewed 590 times
4

0xCursor
- 2,242
- 4
- 15
- 33

noidsirius
- 409
- 2
- 12
-
I think it is impossible.. – ZhaoGang Jan 14 '19 at 02:03
-
I'm not sure how debuggers work entirely, but if they can execute codes step by step (or bytecode by bytecode), it seems feasible to specify a method (or its signature) and set a trigger after it's called. – noidsirius Jan 14 '19 at 02:08
-
in some ide like `xcode`, symbolic breakpoint is what you want. https://stackoverflow.com/questions/13806200/how-to-set-a-breakpoint-on-objectatindex-method-of-a-specific-property-in-a-s. But I don't know if eclipse has such features. – ZhaoGang Jan 14 '19 at 02:23
4 Answers
2
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();
}
}

NeB Nep
- 163
- 12
0
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.

Sanket
- 39
- 1
- 9
0
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.

Andres Olivares
- 53
- 1
- 7