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 61332 - Surround with Try-Catch catches exceptions in wrong order
Summary: Surround with Try-Catch catches exceptions in wrong order
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-25 09:37 UTC by Andrei Badea
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2005-07-25 09:37:54 UTC
[dev build 050705]

1. Have this code:

    InputStream s = new FileInputStream("foo");
    s.read();
    new URL("foo");

2. Use Surround with Try-Catch. You get:

    try {
        InputStream s = new FileInputStream("foo");
        s.read();
        new URL("foo");
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
    } catch (MalformedURLException e) {
    }

The last catch is an error, since MalformedURLException extends IOException, so
MUE is being catched by the catch of IE. Catch statements for classes lower in
the inheritance chain should be generated first. So here it should be:

    try {
        InputStream s = new FileInputStream("foo");
        s.read();
        new URL("foo");
    } catch (FileNotFoundException e) {
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }
Comment 1 Tomas Hurka 2005-07-28 09:41:51 UTC
I will look at it.
Comment 2 Tomas Hurka 2005-07-28 12:11:16 UTC
Fixed in trunk.
Checking in org/netbeans/modules/javacore/TryWrapper.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/TryWrapper.java,v  <--  TryWrapper.java
new revision: 1.11; previous revision: 1.10
done
Comment 3 Andrei Badea 2005-08-02 12:24:23 UTC
Verified.
Comment 4 Quality Engineering 2007-09-20 09:50:51 UTC
Reorganization of java component