Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to write a conditional breakpoint expression that is always true, and executes arbitrary code?
How to write a conditional breakpoint expression that is always true, and executes arbitrary code? [message #1808343] Fri, 21 June 2019 17:42 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 802
Registered: July 2009
Senior Member
I think I've asked this question in the past, but I can't find a record of it.

I want to set the properties for a breakpoint so that a particular piece of valid code is executed when the breakpoint is hit, but I don't want it to stop at the breakpoint. The first part is the most important. If it has to stop at the breakpoint in addition to automatically executing the piece of code, I could live with that.

I'm in a situation where when I hit this line of code, I want to manually set one property that is referenced in the line, so that the behavior changes. I can do this manually, but I'm going to have to do this every time I run this test case, and that's annoying.
Re: How to write a conditional breakpoint expression that is always true, and executes arbitrary cod [message #1808344 is a reply to message #1808343] Fri, 21 June 2019 17:48 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 802
Registered: July 2009
Senior Member
If it matters, not only do I have to call a method to assign the new value, I have to execute that conditionally, only if certain properties are not null.

I was trying to figure out if I could define a ternary operator, where the "true" portion is a lambda that executes arbitrary code and then returns a boolean.
Re: How to write a conditional breakpoint expression that is always true, and executes arbitrary cod [message #1808346 is a reply to message #1808344] Fri, 21 June 2019 18:31 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Don't jump through too many hoops :)
Just be told, that the breakpoint condition is in fact either an expression or a block ending with a return statement ... just freely code whatever you need and then return false; // for "don't suspend"
Re: How to write a conditional breakpoint expression that is always true, and executes arbitrary cod [message #1808360 is a reply to message #1808346] Fri, 21 June 2019 22:54 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 802
Registered: July 2009
Senior Member
Thanks, that works perfectly. I wouldn't have guessed that.
Re: How to write a conditional breakpoint expression that is always true, and executes arbitrary cod [message #1808397 is a reply to message #1808360] Mon, 24 June 2019 04:09 Go to previous message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 131
Registered: February 2010
Location: Bangalore, India
Senior Member
You can also use "Tracepoint" which is a kind of conditional breakpoint and you can put your sysouts without breakpoint stopping at the line of code.

Sarika Sinha
JDT Programmer
Previous Topic:Old ERP system on Java 11 classpath only
Next Topic:Error launching Eclipse
Goto Forum:
  


Current Time: Fri Apr 26 12:46:28 GMT 2024

Powered by FUDForum. Page generated in 0.03768 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top