This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to set breakpoint programmatically under Eclipse?

 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my own ErrorHandler class with a method breakpoint() that does nothing but beg user to "set breakpoint here". It's a bit like a low-tech virus from an old joke, that asks you to delete all your files and forward it to all your friends. Any way I can make Eclipse set a breakpoint, from my Java code?
 
Saloon Keeper
Posts: 21620
147
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. For one thing, what would it do if you weren't running under a debugger? For another thing, the debugger client is what works with breakpoints, and it's typically running in a different VM which may be on a different computer, and it might not even be a Java program at all, since the low-level debugger communications channel involves text commands. Meaning that if I wanted to write a Java debugger in Python, I could do so.

In the case of Eclipse, specifically, you might be able to create an Eclipse plug-in that talked to the Eclipse debugger client, but that seems like a lot of work. It's easier just to throw some sort of Breakpoint exception and tell the Eclipse debugger to halt on breakpoint. I often do that to catch NullPointerExceptions in the act, but any Exception will do, including one you make up for just that purpose.
 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:No. For one thing, what would it do if you weren't running under a debugger?



I don't know.. recover gracefully? I did it in 1999 for VisualAgeForJava, it took 3 lines of code and worked fine.

For another thing, the debugger client is what works with breakpoints, and it's typically running in a different VM which may be on a different computer, and it might not even be a Java program at all, since the low-level debugger communications channel involves text commands. Meaning that if I wanted to write a Java debugger in Python, I could do so.



You are right in principle, but I had specified Eclipse.

In the case of Eclipse, specifically, you might be able to create an Eclipse plug-in that talked to the Eclipse debugger client, but that seems like a lot of work.

Is it? I did not know that, thanks! I was hoping it would be as easy as Visual Age.

It's easier just to throw some sort of Breakpoint exception and tell the Eclipse debugger to halt on breakpoint. I often do that to catch NullPointerExceptions in the act, but any Exception will do, including one you make up for just that purpose.



That's close to what I am doing now, but I "clear all breakpoints" often, and I start with a clean workspace often enough, and will potentially have other users do the same; so it's not ideal.
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!