Bug 61959 - dangerous practice of catching Throwable
Summary: dangerous practice of catching Throwable
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-12 13:56 EDT by Jim des Rivieres CLA
Modified: 2004-05-18 13:50 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 Jim des Rivieres CLA 2004-05-12 13:56:36 EDT
Build I20040512

There are a number of occurrences in this component of the dangerous idiom:

   try {
      ...
   } catch (Throwable e) {
      ... // e not re-thrown
   }

It is very bad practice to catch Throwable (or Error) and eat it because there 
are myriad unrecoverable situations (like out of memory) that this will hide.

A (partial) list of the places that look dangerous are:
org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch - Main.java
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util - Dumper.java
Comment 1 Philipe Mulet CLA 2004-05-12 16:07:59 EDT
The batch compiler is an independant tool which going to trap this exception 
and report it as an internal error. It isn't used inside Eclipse per se. 
Though we could probably only catch RuntimeException which are the ones we do 
mean to catch anyway here.

Need to look closer at Dumper.
Comment 2 Jerome Lanneluc CLA 2004-05-12 18:00:56 EDT
Just checked that Dumper (and IDumpable) are not used in jdt.core. We should 
just delete those.
Comment 3 Philipe Mulet CLA 2004-05-12 18:29:52 EDT
Removed Dumper & IDumpable.
Comment 4 Philipe Mulet CLA 2004-05-13 06:58:17 EDT
Replacing catch Throwable in compiler with: catch RuntimeException.
VM traps are now surfaced. 

Fixed
Comment 5 Olivier Thomann CLA 2004-05-18 13:50:23 EDT
Verified in 200405180816