Bug 24307 - Add compiler warning/error for empty catch blocks
Summary: Add compiler warning/error for empty catch blocks
Status: RESOLVED DUPLICATE of bug 32285
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-02 06:44 EDT by Channing Walton CLA
Modified: 2003-08-28 12:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Channing Walton CLA 2002-10-02 06:44:20 EDT
Hi I would like a compiler warning or error for empty catch blocks like this:
try {
    ...
}
    catch (Exception e) {
}
Comment 1 Adam Kiezun CLA 2002-10-02 07:31:25 EDT
optionally (minor):  unless marked by e.g. @ignore (or other user defined tag)
Comment 2 Channing Walton CLA 2002-10-02 07:45:37 EDT
I would suggest that the catch block is considered empty only if there is white 
space between the braces.
Comment 3 Adam Kiezun CLA 2002-10-02 09:01:19 EDT
hmm, this looks pretty empty too:
catch(Exception e){}  //no white space
or 
catch(Exception e){;} //only empty statements

Comment 4 Channing Walton CLA 2002-10-02 09:24:27 EDT
yup - need to get those too.
Comment 5 Philipe Mulet CLA 2002-10-02 10:00:08 EDT
Nice to have. Rather some QA tool job.
Comment 6 Channing Walton CLA 2002-10-02 10:08:56 EDT
OK, I just felt that since you have quite a number of options for the compiler, 
this would be a good addition.

Channing
Comment 7 Philipe Mulet CLA 2002-10-09 09:25:43 EDT
True, but I am tempted to think this one is just deluxe... plus it is not super 
trivial since it would need to recognize some special comment.

We'll keep this suggestion, and will defer it until more people ask for it.
Comment 8 Channing Walton CLA 2002-10-09 09:46:39 EDT
OK sounds good.
Comment 9 Philipe Mulet CLA 2003-08-28 12:50:56 EDT
Addressed in dup PR.
Comment 10 Philipe Mulet CLA 2003-08-28 12:51:48 EDT

*** This bug has been marked as a duplicate of 32285 ***