Axel
Axel

Reputation: 14159

Is it possible to set a breakpoint on assert in eclipse?

I have a large project consisting of several thousand classes. Today I discovered that for some input, a different result is calculated when running with assertions enabled.

Since the assertion itself doesn't throw an AssertionError (I already have a breakpoint on that one), this means that somewhere hidden in the code is an assertion statement that has an unwanted side effect. The problem is I have no clue which of my >100 assertions is causing the problem.

Since assert is not a method but a keywordin Java, I am at a loss on how to set a breakpoint that will be hit each time assert is called.

Possible workarounds I have found:

Nonetheless, I would like to know if anyone knows of a way to break on assert, even if the condition evaluates to true.

Upvotes: 4

Views: 1765

Answers (1)

Fracdroid
Fracdroid

Reputation: 1163

Goto Run->Add Java Exception Breakpoint Type 'AssertionError' in search box Choose java.lang.AssertionError and OK

Now Eclipse will suspend on assert

Upvotes: 6

Related Questions