Hi,

I don't know if that has been reported before...

There is a problem when a method that can throw an exception
is used as a ctor-parameter for an anonymous class. The
exception is wrongly marked as not handled even when the
containing method declares it in its throws-clause.


Example:

import java.io.IOException;
import java.io.FilterInputStream;
import java.io.InputStream;

public class Test {

    public void test1() throws IOException {
        InputStream is = new FilterInputStream(getInputStream()) {
//Unhandled exception: java.io.IOException --> ^^^^^^^^^^^^^^^^

            public void close() throws IOException {
                super.close();
            }
        };
    }

    public void test2() throws IOException {
        // Introduce variable solves the problem...
        InputStream inputStream = getInputStream();
        InputStream is = new FilterInputStream(inputStream) {
            public void close() throws IOException {
                super.close();
            }
        };
    }

    private InputStream getInputStream() throws IOException {
        throw new IOException();
    }
}

The above code compiles fine, but is rejected by IDEA.



--

Sascha




_______________________________________________
Eap-bugs mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-bugs

Reply via email to