Method with two exception type parameters
Neal Gafter
neal at gafter.com
Mon May 19 01:11:20 PDT 2008
I believe this should be made to work. I'll investigate.
Thanks for the report!
Regards,
Neal
On Mon, May 19, 2008 at 1:03 AM, Zdenek Tronicek <tronicek at fel.cvut.cz>
wrote:
> We can declare a method with two exception type parameters:
>
> static <throws X extends IOException, Y extends InterruptedException>
> void perform({ => void throws X, Y } p) throws X, Y {
> p.invoke();
> }
>
> But how to call it? This does not compile.
>
> try {
> perform({ => Thread.sleep(100); new FileWriter("x").close(); });
> } catch (IOException | InterruptedException e) {
> System.out.println(e);
> }
>
> However, this compiles:
>
> try {
> perform({ => Thread.sleep(100); });
> } catch (InterruptedException e) {
> System.out.println(e);
> }
>
> And this not:
>
> try {
> perform({ => new FileWriter("x").close(); });
> } catch (IOException e) {
> System.out.println(e);
> }
>
>
> Z.
> --
> Zdenek Tronicek
> Department of Computer Science and Engineering
> Prague tel: +420 2 2435 7410
> http://cs.felk.cvut.cz/~tronicek <http://cs.felk.cvut.cz/%7Etronicek>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080519/29714b36/attachment.html
More information about the closures-dev
mailing list