Android Studio: Create well-behaved Exception Breakpoint - java

I just used Android Studio to make an unmodified empty Android app. I'm trying to set an exception breakpoint.
The default exception breakpoint triggers repeatedly. So I added !(this instance of java.lang.ClassNotFoundException) as a condition, as suggested in this question.
However, I still get interrupted by my exception, this time with a modal dialog box:
How do I make an exception breakpoint that will stay silent until something exceptional happens?
Edited to clarify: I don't want to make a breakpoint for a specific exception, I want a general exception breakpoint that I can leave on at all times.

The key here is to use class filters in conjunction with configuration to break on all errors, setting them to very high-level namespaces.
Check the Class filters checkbox to enable class filtering. Then click the ... (elipsis) button to open the Class Filters dialog.
Specify class namespace patterns by clicking on the (Add Pattern) button. Enter:
com.myapp.* (replace this with the namespace prefix of your app)
java.*
android.*
Add any additional namespaces as necessary (e.g. 3rd party libraries)
Press OK
See here for full instructions.

Android Studio is essentially IntelliJ IDEA. You have got to use the + button in the top left corner of the Breakpoints screen to add a breakpoint for a specific exception.
See the following thread for details:
How to use Intellij Idea's exception breakpoints

Related

Netbeans with Java how to find the source of an error?

I use Netbeans for my Java IDE. I am building off a 3rd party API. I have built quite a bit on top of it. I try to leave good debugging messages around my code, but I am getting a very basic error message, then my program is closing. I get this Error - java.io.EOFException and then shortly after the program closes. I think it is just a system output printed line showing the error coming from the API.
Does anyone know of a technique in Netbeans of Java in general where I could identify where the error is coming from?
One can put a break point on the constructor for EOFException().
To do so:
From the menu select Window -> Debugging -> Breakpoints or (Alt+Shift+5)
In the Breakpoints window, right click for pop-up and choose New Breakpoint ...
Set Breakpoint Type to Method
Set classname to java.io.EOFException, for convenience click the All Methods for given class checkbox. (otherwise you would have to set different breakpoints for the different constructors)
Choose Run -> Debug Project (Ctrl+F5) to debug your program. It should stop when the EOFException is created.
Go to Window -> Debugging -> Call Stack to see where it was called from.

How do I set up IntelliJ IDEA to redeploy changed resources?

I use IntelliJ IDEA and want that my class should be redeployed after I make changes. Eclipse can do this. How does this work in IDEA?
I know that in the run configuration there is "On frame deactivation" and I set it to "Update classes and resources", but this does not work.
Do you hit the "redeploy" button every time you made a change in your class?
There are limitations to class reload, in any Java project. It also depends on what you're using to perform this reload (if you're using a servlet container, etc).
By default, IntelliJ uses HotSwap for its reloading. There are some limitations to it though:
At the moment due to original limitations of Java SDK the HotSwapping is possible ONLY if a method body is altered. In all other cases (like changing method or class signature), the class reload is impossible and the corresponding error message appears.
That said, the instructions for configuring your application to reload can be found here.
To configure reloading behavior
On the main menu, choose File | Settings , and then expand the Debugger node.
Open HotSwap page.
Click one of the radio buttons in the group Reload classes after compilation. You can opt to always reload classes, reload after
confirmation, or never do it.
Take a look at HotswapAgent configuration for InteliJ IDEA

Eclipse Debugging Filter Unwanted Packages

I have been using Eclipse for 2 years for development, but this filter concept I am still struggling to understand during debugging.
I usually debug in remote port mode.
Most of the times, My Eclipse catches the break point/exception in Unwanted Packages [Packages usually from other Sources like Spring, Java ThreadPool etc..] and annoys me by bringing up the debug window.
I would like to configure Eclipse to catch breakpoints in my package only. Just ignore any where else, don't halt them or notify me.
As far as I know we can add package filters for exception breakpoints but for the normal line breakpoints, I think a long way to manually disable one by one will work,
You can look at Eclipse Creating Expression Filter for more information.
This figure provide info ho we can open Java Exception Breakpoint,
I think this should help you:
Window --> Preferences --> Java --> Debug
Uncheck the following:
Suspend exceution on uncaught exceptions
Suspend exceution on compilation errors
Open popup when suspended on exception
Click on Apply & then OK.

I can't figure out how to disable Netbean's code completion without disabling pop-up of suggested code

How do I disable code completion but keep suggestions enabled? Every time I type object.Method() without passing any parameters I get something similar to object.Method(datatype). Netbeans would complete the code after the first parenthesis, (. When I don't want to pass any parameters, I simply type ) once. I would get something like this thanks to auto complete: object.Method())
The null in between () would be replaced by the ) I typed.
I want to be able to see suggested code without ctrl-space and without having netbeans automatically insert the code for me. In netbeans I can disable the auto insertion of the second bracket } after I type the first {. I don't have an option to disable parentheses from auto inserting. The problem is that if I disable code completion, I also disable the automatic pop-up that gives me related code. Any advice?
If you do not want the IDE to perform the project updates, you can disable the build analyzer as follows:
Right-click the project node in the Projects window and select Properties.
In the Project Properties dialog box, click the Code Assistance category.
Deselect the Use Build Analyzer option.
https://netbeans.org/kb/docs/cnd/HowTos.html
It's been awhile since I used NetBeans (personally I prefer IntelliJ), but I believe you're using the wrong setting. Try this: under Tools>Options>Editor>General, uncheck "Insert Closing Bracket Automatically".
See also this other question: NetBeans curly braces auto-closing

Eclipse - Execute Expression on at Point in Code?

Is it possible to have Eclipse execute an arbitrary expression at a particular point in code when debugging?
The Execute/Display functionality allows you to run arbitrary code in the context of debugging. A breakpoint stops flow.
What I'd like is something like a breakpoint that can be inserted at a particular point in a class, doesn't suspend application flow, but instead executes a snippet of code.
The background is I'm trying to debug some multithreaded code which I can't edit, and I want to do some naive System.out.printlns to see when various things happen. If I use breakpoints then the flow of the events will be disturbed.
Aha! There's an undocumented feature whereby conditional breakpoints can execute other code, dubbed 'Printpoints'.
You may use the "Breakpoint Properties" of a breakpoint to add some code. Hit the "Conditional" Checkbox in the dialog and place your code there.

Categories