Community
Participate
Working Groups
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.
Created attachment 195499 [details] Patch under consideration Srikanth, I knew exactly what is happening and hence fixed this up. Please review.
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.
(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.
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.
Satyam, I believe the last test (test027) should be a conform test and not a negative test.
(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.
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.
Created attachment 195717 [details] Proposed patch Patch with Olivier's and Srikanth's comments.
Released in BETA_JAVA7 branch
Verified using patch feature 1.0.0-20110623-0900