1

I'm looking for a command/line that does literally nothing, is as short and simple as possible, but allows me to place a breakpoint on it. (in Eclipse)

What I've tried:

System.out.println(""); //Too long, also it prints an empty line
boolean b = false; //Also too long + could cause interferences
; // Doesn't let me place a breakpoint on it in Eclipse
if (true); //Doesn't trigger

I need this for conditional breakpoints. (certain indexes in a for-loop for example)


I am aware of conditional breakpoints in Eclipse, but I'm still looking for that void line. (partially because of plain interest, and partially because I don't like clicking things and relying purely on the IDE)

d0n.key
  • 1,318
  • 2
  • 18
  • 39
  • 6
    why would you want this? adding code just so you can put a breakpoint? – Stultuske Dec 04 '18 at 15:00
  • Conditional breakpoints. Where I have something like `if (i == arr.length -1) void();` – d0n.key Dec 04 '18 at 15:03
  • 2
    Doesn't eclipse support setting a condition on a breakpoint? – OhleC Dec 04 '18 at 15:05
  • If no debugging on expressions: then it has to be (generated!) code, hence `if (i == 13) {` _[BreakPointHere]_ `i = i^0; }`. A senseless no-op I do not know, as I am a serious developer. – Joop Eggen Dec 04 '18 at 15:14

4 Answers4

2

You could use the assert-Statement:

assert true;

But you have to activate asserts. In Eclipse see Eclipse: enable assertions

Ralf Renz
  • 1,061
  • 5
  • 7
1

Rather than adding code simply for setting breakpoints, you can set a java expression as a breakpoint condition in eclise:

https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F

(other IDEs support this as well, but the question was about Eclipse)

OhleC
  • 2,821
  • 16
  • 29
0

Use empty curly brackets {} , that'll probably do, or Semi-colon ; actually will do as well.

as.hasimy
  • 1
  • 2
  • I've already stated in the question, that Eclipse doesn't allow me to set a breakpoint on `;` - same goes for curly brackets unfortunately. – d0n.key Dec 04 '18 at 15:11
0

This Eclipse page shows that by right-clicking or double clicking the left margin of the Eclipse code editor, you can toggle breakpoints.

This post also has some good info on setting breakpoints.

Edit:

If you don't want to toggle breakpoints through the Eclipse interface, you could just write your own method of type void and call that. For example:

public void wait() {} // Empty method

And then you can just call the method wherever you want to set a breakpoint.

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