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.
NetBeans has a great support that detects exceptions that need to be caught: public Object create() { return Object.class.newInstance(); } will not compile and the IDE gives me following hints: Add throws ... (twice) Surround with try/catch I certainly don't want to declare the exception, so "Add throws..." isn't an option, so let's do "try/catch". The generated code is: public Object create() { try { return Object.class.newInstance(); } catch (InstantiationException ex) { Exceptions.printStackTrace(ex); // either } catch (IllegalAccessException ex) { // or Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } I've seen the code many times, however in 90% of cases I had to re-write it to: try { return Object.class.newInstance(); } catch (InstantiationException ex) { throw new IllegalStateException(ex); } catch (IllegalAccessException ex) { throw new IllegalStateException(ex); } Can't there be a hint "Re-throw (as unchecked) exception" available? Many people would find it useful. Btw. I would also welcome "Re-throw silently" that would generate public Object create() { try { return Object.class.newInstance(); } catch (InstantiationException ex) { throw raise(RuntimeException.class, ex); } catch (IllegalAccessException ex) { throw raise(RuntimeException.class, ex); } } private static <E extends Throwable> E raise(Class<E> type, Throwable t) throws E { throw (E)t; } which I would consider extremely useful, but I can live without it for now.