Exception transparency vs constructors
Neal Gafter
neal at gafter.com
Mon Jul 7 01:22:46 PDT 2008
Mark-
This is indeed a bug in the underlying compiler. Generic constructors are
pretty rare, and type parameters in throws clauses even more so. Apparently
the combination doesn't currently work in javac. The following won't
compile.
*public class Hello {
static class Foo<X> {}
<X extends Throwable> Hello(Foo<X> foo) throws X {}
public static void main(String[] args) throws Exception {
new Hello(new Foo<Exception>());
}
}*
I've reported this as a bug against javac.
Regards,
Neal
On Thu, May 15, 2008 at 7:22 PM, Neal Gafter <neal at gafter.com> wrote:
> Got it, thanks! I suspect some of these are symptoms of existing problems,
> but either way I'll track them down.
>
> Regards,
> Neal
>
>
> On Thu, May 15, 2008 at 6:22 PM, Mark Mahieu <
> mark at twistedbanana.demon.co.uk> wrote:
>
>> It looks like exception transparency isn't working quite right with
>> constructors - I think the following class should compile, but it doesn't:
>>
>>
>> public class ExTrans {
>>
>> <throws X> ExTrans({=> void throws X} block) throws X {
>> block.invoke();
>> }
>>
>> public static void main(String[] args) throws Exception {
>> new ExTrans({=> throw new Exception(); });
>> }
>> }
>>
>>
>>
>> ExTrans.java:8: unreported exception X; must be caught or declared to be
>> thrown
>> new ExTrans({=> throw new Exception(); });
>> ^
>> 1 error
>>
>>
>>
>> Regards,
>>
>> Mark
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080707/0cf78382/attachment.html
More information about the closures-dev
mailing list