Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 236524 - "Remove catch statement" should not remove entire multicatch block
"Remove catch statement" should not remove entire multicatch block
Product: java
Classification: Unclassified
Component: Hints
PC Windows 7
: P3 (vote)
: 8.0
Assigned To: Svata Dedic
: 236808 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2013-09-29 22:33 UTC by _ gtzabari
Modified: 2013-10-15 11:43 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT

Proposed patch to nb-javac (3.62 KB, patch)
2013-10-14 07:34 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-09-29 22:33:35 UTC
Product Version: NetBeans IDE Dev (Build 201309270002)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
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

1. Given:

  // throws A, B
catch (A | B | C e)

2. Netbeans flags multicatch line with "exception C is never thrown in the body of the corresponding try statement" and offers a hint "Remove catch clause".
3. If you apply the hint, Netbeans removes the entire multicatch statement.

Expected behavior: Hint should remove "C" from multicatch block, as opposed to removing the entire block.
Comment 1 Svata Dedic 2013-10-14 07:34:22 UTC
NB javac currently reports position that corresponds to the entire 'catch' clause as if the reporting code was not updated when multicatch was added.

Dusane, please review a small patch; it should report the Type tree for the offending exception type in a multicatch clause, but should retain the behaviour for normal catches.
Comment 2 Svata Dedic 2013-10-14 07:34:49 UTC
Created attachment 141047 [details]
Proposed patch to nb-javac
Comment 3 Svata Dedic 2013-10-14 07:35:32 UTC
just ignore the project related changes, sorry. The only file to be modified is
Comment 4 Dusan Balek 2013-10-14 07:38:48 UTC
The proposed patch looks OK to me.
Comment 5 Svata Dedic 2013-10-14 08:12:12 UTC
Fixed in rev, pending nb-javac patch nb-javac#698f6461a3bb
Comment 7 Jiri Prox 2013-10-15 11:43:48 UTC
*** Bug 236808 has been marked as a duplicate of this bug. ***

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo