Summary: | Erroneous compiler warning about hidden catch block | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jim Pinkham <jpinkham> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | ||
Version: | 2.0.2 | ||
Target Milestone: | 2.1 M5 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Jim Pinkham
2002-12-18 14:06:31 EST
This is an optional warning which you can turn off if you don't like it. The rational is that if you would separate these 2 catch blocks in nested try statements, the outer catch would get a blame (claiming its unreachable). Isn't it the case ? Based on the wording of the message, I think it is trying to warn of an unreachable catch block where the superclass is first and the subclass second. (I would think that should be an unreachable code error, not a warning). If it is truly working as intended, then I guess I just don't get it. I don't see how the use of multiple catch blocks with catch (specific class) ... catch (subclass) is something to be discouraged with a warning? Sure, I can turn it off (thus low severity), but it seems like an incorrect warning to me. (The second block is NOT hidden.) I'm sorry I don't understand what you mean about separating the 2 catch blocks? If you wrote instead the following code, wouldn't the outer catch be flagged as being unreachable ? try { try { ... stuff using XML transformers ... retVal = transformerFactory.newTransformer(new StreamSource(new File (xslFileLocation.toString()))); xslTransformers.put(xslKey, retVal); } catch(TransformerConfigurationException e) { throw new RemoteException("oh, darn!", e); } } catch(TransformerException e) { <-- The warning's red squiggle appears under the brace here throw new RemoteException("oh, double darn!", e); } No, in that case the outer catch would still be reachable (assuming the stuff in the inner try block is declared to throw TransformerException and not just TransformerConfigurationException). So if it threw some other subclass it would go to the outer catch block. Since I first posted this bug, I found the help description of the intent of the message. It appears to be doing exactly what is intended, so I'm marking this as INVALID (aka Not a bug). I still don't undertand why anyone would want such a warning, but there is so much to love about Eclipse, I'll just turn it off and move on. |