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.

Bug 236524

Summary: "Remove catch statement" should not remove entire multicatch block
Product: java Reporter: _ gtzabari <gtzabari>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal CC: ajeh, dbalek
Priority: P3    
Version: 7.4   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:
Attachments: Proposed patch to nb-javac

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:

try
{
  // 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 Flow.java
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 http://hg.netbeans.org/jet-main/rev/838c029341ab, 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. ***