Bug 356560 - [1.7][compiler] Incorrect exception handling when using try-with-resources
Summary: [1.7][compiler] Incorrect exception handling when using try-with-resources
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-02 04:44 EDT by Vincent PERICART CLA
Modified: 2011-09-12 03:10 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 Vincent PERICART CLA 2011-09-02 04:44:53 EDT
Build Identifier: I20110805-1200

The following snippet will compile without warning on JDK7.

    private static void closeThat(Closeable that) throws IOException {
        try (Closeable toClose = that) {
            // closes toClose
        }
    }

Though, on Eclipse, it will output a warning ("The declared exception IOException is not actually thrown...").

Removing the exception :

    private static void closeThat(Closeable that) {
        try (Closeable toClose = that) {
            // closes toClose
        }
    }

will pass the compiler check on Eclipse, but will fail to compile with the JDK7.
It is indeed translateable to : 

    private static void closeThat(Closeable that) {
        Closeable toClose = that;
        try {
           
        } finally {
            toClose.close(); // throws IOException
        }
    }


Reproducible: Always

Steps to Reproduce:
1. Input provided code in Eclipse Java editor
Comment 1 Olivier Thomann CLA 2011-09-02 10:54:36 EDT
This seems to be fixed in HEAD and 3.7 maintenance.
Could you please provide the org.eclipse.jdt.core bundle id ?
You can find it into Help>About Eclipse SDK>Installation Details>Plugins.
Comment 2 Olivier Thomann CLA 2011-09-09 09:23:58 EDT
Closing as WORKSFORME.
Satyam, if you can find the duplicate, you can close it as a dup.
Comment 3 Satyam Kandula CLA 2011-09-12 03:10:02 EDT
I am not able to reproduce even with the build of I20110802-2000.
Verified for 3.8M2 with build I20110911-2000