Bug 14818

Summary: no message for uncaught exception in try block when return in finally
Product: [Eclipse Project] JDT Reporter: John Dale <john>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: 2.0 M6   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description John Dale CLA 2002-04-28 14:38:06 EDT
When the finally clause includes return, no compile-time message is generated 
for uncaught exceptions in the try clause.  When I save this code in Eclipse, 
no compile-time error is reported.  (However, without the return statement in 
the finally block, the uncaught exception is detected.)

public class UncaughtNotDetected {
  void test() {
    try {
      thrower();
    } finally {
      return;
    }
  }
  void thrower() throws java.lang.Exception {
    throw new java.lang.Exception();
  }
}

For comparison, when compiled using JDK 1.3.1 javac, the following is reported
UncaughtNotDetected.java:4: unreported exception java.lang.Exception; must be 
caught or declared to be thrown

Using Eclipse Versoin R1.0 Build 0.137
Comment 1 John Dale CLA 2002-04-28 15:15:58 EDT
This is not a bug in the Eclipse compiler.  As described in Bug 13906, the test
() method should, as described JLS(2nd edition) 14.19.2, throw the exception, 
and hence the compiler should consider the code valid.

*** This bug has been marked as a duplicate of 13906 ***
Comment 2 John Dale CLA 2002-04-28 15:21:25 EDT
Correction of earlier comment, inserting missing "NOT":

This is not a bug in the Eclipse compiler.  As described in Bug 13906 referring 
to JLS(2nd edition) 14.19.2, test() should NOT throw the exception, and hence 
the compiler should consider the code valid, as it does.  JDK 1.3.1 javac is 
wrong.
Comment 3 Philipe Mulet CLA 2002-04-29 05:17:44 EDT
Indeed this is a javac bug.