Bug 14818 - no message for uncaught exception in try block when return in finally
Summary: no message for uncaught exception in try block when return in finally
Status: RESOLVED DUPLICATE of bug 13906
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-28 14:38 EDT by John Dale CLA
Modified: 2002-04-29 05:17 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.