Skip to main content



      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 13:42 Go to next message
Eclipse UserFriend
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 13:48 Go to previous messageGo to next message
Eclipse UserFriend
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 14:31 Go to previous messageGo to next message
Eclipse UserFriend
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 18:54 Go to previous messageGo to next message
Eclipse UserFriend
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 00:09 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Old ERP system on Java 11 classpath only
Next Topic:Error launching Eclipse
Goto Forum:
  


Current Time: Wed Jul 02 14:23:59 EDT 2025

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

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

Back to the top