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.
Product Version: NetBeans IDE Dev (Build 201402190001) Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b66 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b124 System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb) User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev Given: public class JavaApplication2 { public static void main(String[] args) { try { System.out.println("foo"); } catch (RuntimeException e) { throw new RuntimeException(e.getCause()); } } } Netbeans flags the line with e.getCause() with "Throwable method result is ignored" when in fact the result is not ignored.
Another example seen in Build 201401141042 on Linux: The use of the value returned from Throwable.getCause() produces a warning in foo() below which prints it out with a .toString() call, but simply printing it out in bar() (which uses the .toString() within println(..)) does not. @SuppressWarnings("UseOfSystemOutOrSystemErr") public static Object foo (java.lang.reflect.Method m) { try { return m.invoke(null); } catch (InvocationTargetException t) { System.err.println(t.getCause().toString()); // <-- Throwable method result is ignored System.exit(-1); return null; } catch (IllegalAccessException t) { return null; } } @SuppressWarnings("UseOfSystemOutOrSystemErr") public static Object bar (java.lang.reflect.Method m) { try { return m.invoke(null); } catch (InvocationTargetException t) { System.err.println(t.getCause()); // <-- No hint System.exit(-1); return null; } catch (IllegalAccessException t) { return null; } }
fixed in jet-main#cdaa213ec845
Integrated into 'main-silver', will be available in build *201403150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/cdaa213ec845 User: Svata Dedic <sdedic@netbeans.org> Log: #242212: detection of throwable usage improved
This problem is still present in version 8.0.2 Product Version = NetBeans IDE 8.0.2 (Build 201411181905) Operating System = Mac OS X version 10.10.2 running on x86_64 Java; VM; Vendor = 1.7.0_67 Runtime = Java HotSpot(TM) 64-Bit Server VM 24.65-b04 try { // ... throw new OrmException("example"); } catch (OrmException maybeSqlTransactionRollbackException) { Throwable cause = maybeSqlTransactionRollbackException.getCause(); // <--- Erroneous hint here if (ChangesOnSlave.retryOnDeadlocks && (cause instanceof SQLTransactionRollbackException)) { // ... } else { throw maybeSqlTransactionRollbackException; } } NetBeans will still say that the cause is ignored even if it's used in the following if
(In reply to achirizzi from comment #4) > This problem is still present in version 8.0.2 I suggest opening a separate issue because the Affected Version is different. It could very well be that this was fixed in 8.0.1 and a regression in 8.0.2. Either way, 8.0.1 was already released.
Opened bug 251944. Thanks
Setting back to fixed, the specific case was fixed as issue #251944