Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345579 - [1.7][compiler] Weird error message in rethrow site
Summary: [1.7][compiler] Weird error message in rethrow site
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Satyam Kandula CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-12 06:53 EDT by Srikanth Sankaran CLA
Modified: 2011-08-05 02:54 EDT (History)
3 users (show)

See Also:
srikanth_sankaran: review+


Attachments
Patch under consideration (2.51 KB, patch)
2011-05-12 10:43 EDT, Satyam Kandula CLA
no flags Details | Diff
Patch under consideration (7.62 KB, patch)
2011-05-13 06:48 EDT, Satyam Kandula CLA
no flags Details | Diff
Proposed patch (7.76 KB, patch)
2011-05-16 07:00 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2011-05-12 06:53:46 EDT
Follow up of bug 345522: BETA_JAVA7

public class X {
    X() throws Exception {
        try {
            throw (Throwable) new Exception();
        } catch (Exception e) {
            throw e;   // <<<<----------------  here
        } catch (Throwable e) {
        }
    }
}

On this program eclipse reports an error "Unhandled exception type Throwable"

JDK7 compiles it alright.
Comment 1 Satyam Kandula CLA 2011-05-12 10:43:59 EDT
Created attachment 195499 [details]
Patch under consideration

Srikanth, I knew exactly what is happening and hence fixed this up. Please review.
Comment 2 Srikanth Sankaran CLA 2011-05-13 02:39:57 EDT
Even with precise exception analysis, JDK7 does not flag the first
catch block as unreachable.

public class X {
	void foo() {
		try {
			goo();
		} catch(SubTypeOfSpecialException e) {
			
		} catch (SpecialException e) {
			
		}
	}
	void goo() throws SpecialException {
		
	}
}

class SpecialException extends Exception {}
class SubTypeOfSpecialException extends SpecialException {}

Eclipse conforms at the moment.
Comment 3 Srikanth Sankaran CLA 2011-05-13 03:24:56 EDT
(In reply to comment #2)
> Even with precise exception analysis, JDK7 does not flag the first
> catch block as unreachable.

Satyam pointed out my muddled thinking, this block can of course be
reached based on what actually gets thrown. So comment#2 should be
ignored.
Comment 4 Satyam Kandula CLA 2011-05-13 06:48:47 EDT
Created attachment 195578 [details]
Patch under consideration

Srikanth has pointed out that the earlier patch haven't considered InitializationFlowContext. The earlier patch though will not cause problems, but it is not clean. In this patch, I am passing a new parameter which will tell the exception that the particular catch block will process.

Srikanth, please review.
Comment 5 Olivier Thomann CLA 2011-05-13 10:33:29 EDT
Satyam,

I believe the last test (test027) should be a conform test and not a negative test.
Comment 6 Satyam Kandula CLA 2011-05-13 11:16:57 EDT
(In reply to comment #5)
> Satyam,
> 
> I believe the last test (test027) should be a conform test and not a negative
> test.
Yes, I will change it accordingly. Thanks.
Comment 7 Srikanth Sankaran CLA 2011-05-16 02:03:59 EDT
Patch looks good. Please release after (a) making the change
suggested in comment# 4. (b) I think it is better to short circuit the
call to org.eclipse.jdt.internal.compiler.lookup.CatchParameterBinding.setPreciseType(TypeBinding) if caughtException is null.
Comment 8 Satyam Kandula CLA 2011-05-16 07:00:20 EDT
Created attachment 195717 [details]
Proposed patch

Patch with Olivier's and Srikanth's comments.
Comment 9 Satyam Kandula CLA 2011-05-16 07:02:52 EDT
Released in BETA_JAVA7 branch
Comment 10 Stephan Herrmann CLA 2011-06-28 09:39:54 EDT
Verified using patch feature 1.0.0-20110623-0900