Bug 75878 - [misc] Mark exception occurrences could ignore already catched code
Summary: [misc] Mark exception occurrences could ignore already catched code
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2004-10-08 06:14 EDT by Tom Hofmann CLA
Modified: 2015-04-28 04:57 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2004-10-08 06:14:44 EDT
3.1 M2

This may be hard, but anyway... Consider this fragment of code:

try {
	FileOutputStream output= new FileOutputStream(file); // throws FNFEx
	output.close(); // throws IOEx
} catch (FileNotFoundException e) {
	// error opening file
} catch (IOException e) {
	// error closing file
}

The only exception thrown by the first statement is FileNotFoundException, which
is caught by the first catch block. When putting the caret on 'IOException', the
first statement gets still highlighted, even though it is not a valid path.

An implementation of this feature request would have to analyze the other catch
blocks and check the type hierarchies for subclasses...
Comment 1 Dani Megert CLA 2004-10-08 06:44:29 EDT
On one side it's a cool feature on the other side it hides information.
Comment 2 Tobias Widmer CLA 2005-10-20 10:49:57 EDT
Another, more common example:

InputStream stream= ...
try {
  ... = stream.read();
  try {	
    stream.close();
  } catch (IOException exception) {
  }
} catch (IOException exception) {
}

Selecting the last occurrence of IOException should not highlight "stream.close
()".
Comment 3 Markus Keller CLA 2009-01-05 09:30:46 EST
(In reply to comment #2)
> Another, more common example:

That's a different bug, see bug 68305.


(In reply to comment #0)
> This may be hard, [..]

Not too hard, since the ExceptionOccurrencesFinder already has an AST with bindings and does not need to create type hierarchies, etc.
Comment 4 Gerrit CLA 2015-04-28 04:57:29 EDT
Today I also came across that behaviour in Eclipse v.3.7.2. First I was a little bit confused and thought the mistake was on my side. But then I discovered that Eclipse doesn't care for exceptions which are caught by another catch block of the same try block.

(In reply to Dani Megert from comment #1)
> On one side it's a cool feature on the other side it hides information.

I agree to that. But it would be nice to implement that depending on your configuration. The default behaviour would be like it is now. But clicking on a check-box in the Eclipse preference could change that behaviour to the one mentioned by Tom Hofmann.