Bug 298743 - [quick fix] Quick fix "replace catch clause with throws" is enabled even if it will give compile errors
Summary: [quick fix] Quick fix "replace catch clause with throws" is enabled even if i...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2010-01-04 06:40 EST by David Burström CLA
Modified: 2010-01-04 09:51 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Burström CLA 2010-01-04 06:40:03 EST
Build Identifier: M20090917-0800

When using quick assist on the "catch" row below, it suggests replacing the catch with a throws clause. In the example, this leads to compile errors, since run() cannot be redeclared to throw an IOException. This fact is probably known by the IDE when quick assist is invoked, so the option should be removed.

import java.io.IOException;
public class Test extends Thread {
    @Override
    public void run() {
        try {
        } catch (IOException e) {
        }
    }
}

Reproducible: Always

Steps to Reproduce:
1. Create a class like the following:
import java.io.IOException;
public class Test extends Thread {
    @Override
    public void run() {
        try {
        } catch (IOException e) {
        }
    }
}
2. Run quick assist on the error and select "replace catch clause with throws".
3. Observe the new compile error.
Comment 1 Frederic Fusier CLA 2010-01-04 08:42:40 EST
Move to JDT/UI
Comment 2 Markus Keller CLA 2010-01-04 09:51:20 EST
We could test overridden methods and not show the quick fix if the exception is checked, and there is an overridden method that is not in source and that does not include the given exception in its throws clause.

In other cases, we should still keep it, because the user may in fact also want to update the overridden method later.