Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351441 - [1.7] Exception occurrences are not marked correctly when an exception in throws declaration is selected.
Summary: [1.7] Exception occurrences are not marked correctly when an exception in thr...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 09:04 EDT by Deepak Azad CLA
Modified: 2011-08-02 05:45 EDT (History)
3 users (show)

See Also:


Attachments
fix + test (5.35 KB, patch)
2011-07-09 01:31 EDT, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-07-07 09:04:32 EDT
Fix to go in ExceptionOccurrencesFinder. Essentially the changes already done for UnionType and twr do not fix the case when an exception in throws declaration is selected.
Comment 1 Deepak Azad CLA 2011-07-07 10:38:55 EDT
In the following snippet select void (the return type), and exit points will be marked including the closing } of twr and resource constructors. These are not marked when Throwable is selected in the throws clause.
--------------------------------------------------------------------------------
	void foo5() throws Throwable {
		FileReader reader = new FileReader("file1");
		try (FileReader reader1 = new FileReader("file1");
				FileReader reader2 = new FileReader("file2")) {
			int ch;
			while ((ch = reader1.read()) != -1) {
				reader.read();
			}
		}
	}
--------------------------------------------------------------------------------

While looking into this I also ran into an older issue. In the following snippet select 'Exception' in the throws clause => all three throw statements are marked even though 2 of the exceptions are caught. This is slightly different (and simpler to fix) than bug 75878 and bug 68305.
----------------------------------------------------------------------------
	void foo(String s) throws Exception {
		try {
			if (s == null)
				throw new NullPointerException();
			else if (s.length() > 10)
				throw new IllegalArgumentException();
			else
				throw new Exception();
		} catch (NullPointerException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}
	}
----------------------------------------------------------------------------
Comment 2 Markus Keller CLA 2011-07-07 10:51:34 EDT
Looks the same as bug 68305. Here, the outer scope is the "throws" clause whereas in bug 68305, it's the outer "try" statement. Necessary analysis is exactly the same.
Comment 3 Deepak Azad CLA 2011-07-09 01:31:34 EDT
Created attachment 199369 [details]
fix + test

(In reply to comment #1)
> In the following snippet select void (the return type), and exit points will be
> marked including the closing } of twr and resource constructors. These are not
> marked when Throwable is selected in the throws clause.
> --------------------------------------------------------------------------------
>     void foo5() throws Throwable {
>         FileReader reader = new FileReader("file1");
>         try (FileReader reader1 = new FileReader("file1");
>                 FileReader reader2 = new FileReader("file2")) {
>             int ch;
>             while ((ch = reader1.read()) != -1) {
>                 reader.read();
>             }
>         }
>     }
> --------------------------------------------------------------------------------

For now I have fixed the above problem. Bug 68305 is an older issue, which I think we should fix for 3.7.1.
Comment 4 Deepak Azad CLA 2011-07-09 01:36:20 EDT
.
Comment 5 Ayushman Jain CLA 2011-07-20 02:56:02 EDT
Verified using JDT feature patch v20110714-1300.