This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
High priority enhancement because of existing traps. If in a debug session an uncaught exception is about to be thrown in a application then the debugger should treat the exception in very much the same way as a breakpoint. I remember there was such support in Sun's Java Workshop IDE. I was overwhelmed by that particular functionality in JWS at the time, maybe it was ahead of its time and out of line with the rest of it. Today I am overwhelmed by the awsome functionality of NetBeans as a whole which is 10 times better but I am missing exception support for a very practical reason. Please consider and run the following testcase and you will instantly recognise the critical need. The testcase alone is shocking, and the fact that the NetBeans debugger does not offer any help is a little disappointing. To appreciate the full imact please consider an application that uses a 3rd party component such as a relational database engine that throws an error and the application does not even notice. Now you have to debug this thing and the debugger simply throws the towel. Lots of swaering in this scenario I promise. Here's the testcase: class Test{ public static void main(String[] args){ int status = 1; try{ status = getNumber(); System.err.println("status = " + status); }// try catch(NumberFormatException ex){ // This Exception is never thrown; only used to // have a basic try/catch block System.err.println("NumberFormatException caught"); ex.printStackTrace(); }// catch finally{ if(status != 0){ System.err.println("Test failed - number not set. Any stack trace printed?"); }// System.out.println("Closing down."); System.exit(status); }// finally }// method private static int getNumber() throws NumberFormatException{ if(true){ throw new NullPointerException(); }// if return 0; }// method }// class
We already have exception support in the debugger. We call it exception breakpoints or breakpoints on exception. You can add breakpoint that will suspend debugger when the exception is thrown: 1. Open Add Breakpoint dialog through Debug | Add Breakpoint 2. Select Exception from the Breakpoint Type combobox. 3. Specify package name and class name of your exception. (You can fill in java.lang.Exception if you wish to stop debugger on any exception). 4. Specify whether the breakpoint should stop on exceptions that will be caught or uncaught. Notes: 1. It seems that you are confused that stack trace is not printed, its because of the call System.exit() in the finally block. VM is terminated and the exception is not propagated out of the thread => it is not printed. 2. Breakpoints on uncaught exceptions can be confusing (as you can see from your testcase if you remove the System.exit() call). When the uncaught NullPointerException is thrown, the debugger reports that caught exception was thrown. That's because the exception is "caught" by the finally block. Another uncaught exception is reported inside the finally block. That's because the previous exception which was caught by the finally block was "rethrown".
Resolved for 3.3.x or earlier, no new info since then -> closing.